Package lt.refactory.primsAlgo.graph

Examples of lt.refactory.primsAlgo.graph.Edge


 
  public static WeightedEdge getMiddleEdge(Edge mainEdge, Edge nearEdge) {
    BigDecimal midX = mainEdge.getEnd().getPointX().add(mainEdge.getStart().getPointX()).divide(BigDecimal.valueOf(2));
    BigDecimal midY = mainEdge.getEnd().getPointY().add(mainEdge.getStart().getPointY()).divide(BigDecimal.valueOf(2));
    Node anotherPoint = mainEdge.containsNode(nearEdge.getStart()) ? nearEdge.getEnd() : nearEdge.getStart();
    Edge midEdge = new Edge(new Node(midX, midY), anotherPoint);
   
    return new WeightedEdge(midEdge, getEdgeLength(midEdge));
  }
View Full Code Here


   
    if (resultNodes.size() != 2) {
      throw new AlgorithmException("Found more or less edges than needed");
    }
   
    Edge resultEdge = new Edge(resultNodes.get(0), resultNodes.get(1));
    BigDecimal weight = getEdgeLength(resultEdge);
   
    return new WeightedEdge(resultEdge, weight);
  }
View Full Code Here

    // remove old edges
    currentGraph.removeEdge(edge);
    currentGraph.removeEdge(nearEdge);
   
    // create new adges
    Edge firstNewEdge = new Edge(commonPoint, steinerPoint);
    Edge secondNewEdge;
    Edge thirdNewEdge;
   
    if (edge.getStart().equals(commonPoint)) {
      secondNewEdge = new Edge(edge.getEnd(), steinerPoint);
    } else {
      secondNewEdge = new Edge(edge.getStart(), steinerPoint);
    }
   
    if (nearEdge.getStart().equals(commonPoint)) {
      thirdNewEdge = new Edge(nearEdge.getEnd(), steinerPoint);
    } else {
      thirdNewEdge = new Edge(nearEdge.getStart(), steinerPoint);
    }
   
    WeightedEdge firstWeightedEdge = new WeightedEdge(firstNewEdge, getEdgeLength(firstNewEdge));
    WeightedEdge secondWeightedEdge = new WeightedEdge(secondNewEdge, getEdgeLength(secondNewEdge));
    WeightedEdge thirdWeightedEdge = new WeightedEdge(thirdNewEdge, getEdgeLength(thirdNewEdge));
View Full Code Here

      
     }
     static List<Edge> edgeFactory(){
      List<Node> nodeList = TestObjectsFactory.nodesFactory();
      List<Edge> edgeList = new ArrayList<>();
      edgeList.add(new Edge(nodeList.get(0),nodeList.get(6)));
      edgeList.add(new Edge(nodeList.get(6),nodeList.get(0)));
      edgeList.add(new Edge(nodeList.get(0),nodeList.get(5)));
        edgeList.add(new Edge(nodeList.get(5),nodeList.get(1)));
      edgeList.add(new Edge(nodeList.get(1),nodeList.get(5)));
      edgeList.add(new Edge(nodeList.get(1),nodeList.get(6)));
      edgeList.add(new Edge(nodeList.get(5),nodeList.get(6)));
      edgeList.add(new Edge(nodeList.get(4),nodeList.get(5)));
      edgeList.add(new Edge(nodeList.get(2),nodeList.get(6)));
      edgeList.add(new Edge(nodeList.get(2),nodeList.get(3)));
      edgeList.add(new Edge(nodeList.get(0),nodeList.get(8)));
      edgeList.add(new Edge(nodeList.get(0),nodeList.get(7)));
      edgeList.add(new Edge(nodeList.get(8),nodeList.get(9)));
      edgeList.add(new Edge(nodeList.get(0),nodeList.get(9)));
      edgeList.add(new Edge(nodeList.get(9),nodeList.get(0)));
     
     
      return edgeList;
      
     }
View Full Code Here

    assertTrue(nearNodeAList.size()==4);
    assertTrue(nearNodeBList.size()==2);
   
   
   
    graph.removeEdge(new Edge(nodeList.get(0),nodeList.get(6)));
    graph.removeEdge(new Edge(nodeList.get(1),nodeList.get(6)));
    nearNodeAList = graph.getNearNodes(nodeList.get(0));
    nearNodeBList = graph.getNearNodes(nodeList.get(1));
   
    // Removed 1 edge for each checkNode i am testing
    // size for those checkNodes decrease by 1
View Full Code Here

  }
 
  @Test
  public void testEdgeHashCodeAndEquals(){
   
    Edge edge1 = edgeList.get(3);
    Edge edge2 = edgeList.get(4);
   
    assertTrue(edge1.equals(edge2));
    assertTrue(edge1.hashCode() == edge2.hashCode());
  }
View Full Code Here

    nodeList.add(node2);
    nodeList.add(node3);
    nodeList.add(node4);
   
    @SuppressWarnings("unchecked")
    T edge1 = (T) new Edge(node1,node2);
    @SuppressWarnings("unchecked")
    T edge2 = (T) new Edge(node1,node3);
   
    edgeList.add(edge1);
    edgeList.add(edge2);

  }
View Full Code Here

TOP

Related Classes of lt.refactory.primsAlgo.graph.Edge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.