Package org.geotools.graph.path

Examples of org.geotools.graph.path.DijkstraShortestPathFinder


            }
        };

        List<Edge> edgeList = new ArrayList<Edge>();
        for ( int i = 0; i < list.size() - 1; i++ ) {
            DijkstraShortestPathFinder pf = new DijkstraShortestPathFinder( graph, list.get( i ), weighter );
            pf.calculate();
            Path path = pf.getPath( list.get( i + 1 ) );
            if ( path != null ) {
                edgeList.addAll( path.getEdges() );
            }
        }
        mapboard.put( "path", edgeList );
View Full Code Here


        Iterator it = graph.getNodes().iterator();

        Node source = (Node) it.next();

        // create the path finder
        DijkstraShortestPathFinder pf = new DijkstraShortestPathFinder(
                graph, (Graphable) source, costFunction(), tcostFunction());

        pf.calculate();

        Iterator it1 = graph.getNodes().iterator();

        while (it1.hasNext()) {
            Node d = (Node) it1.next();

            Path path = pf.getPath((Graphable) d);

            gotArray.add(pf.getCost(d));

        }

    }
View Full Code Here

   * Expected: 1. Path should contain every node in graph in order.
   */
  public void test_0() {
    int nnodes = 100;
    Node[] ends = GraphTestUtil.buildNoBifurcations(builder(), nnodes);
    DijkstraShortestPathFinder pfinder = new DijkstraShortestPathFinder(
      builder().getGraph(), ends[0], costFunction()
    );
   
    pfinder.calculate();
    Path p = pfinder.getPath(ends[1]);
   
    int count = 99;
    for (Iterator itr = p.iterator(); itr.hasNext();) {
      Node n = (Node)itr.next();
      assertTrue(n.getID() == count--);
View Full Code Here

   */
  public void test_1() {
    int nnodes = 100;
    Node[] ends = GraphTestUtil.buildCircular(builder(), nnodes);
   
    DijkstraShortestPathFinder pfinder = new DijkstraShortestPathFinder(
      builder().getGraph(), ends[0], costFunction()
    );
   
    pfinder.calculate();
    Path p = pfinder.getPath(ends[1]);
   
    assertTrue(p.size() == 2);
    assertTrue(p.get(0) == ends[1]);
    assertTrue(p.get(1) == ends[0]);
  }
View Full Code Here

    int k = 4;
    Object[] obj = GraphTestUtil.buildPerfectBinaryTree(builder(), k);
    Node root = (Node)obj[0];
    Map id2node = (Map)obj[1];
   
    DijkstraShortestPathFinder pfinder = new DijkstraShortestPathFinder(
      builder().getGraph(), root, costFunction()
    );
    pfinder.calculate();
   
    for (Iterator itr = builder().getGraph().getNodes().iterator(); itr.hasNext();) {
      Node node = (Node)itr.next();
      String id = node.getObject().toString();
     
      if (id2node.get(id + ".0") == null) {
        Path p = pfinder.getPath(node);
        assertTrue(p.size() == k+1)
    
        for (Iterator pitr = p.iterator(); pitr.hasNext();) {
          Node n = (Node)pitr.next();
          assertTrue(n.getObject().toString().equals(id));
View Full Code Here

                return geom.getLength();
            }
        };

        //calculate the cost(distance) of each graph node to the node closest to the origin
        shortestPathFinder = new DijkstraShortestPathFinder(networkGraph, source, edgeWeighter);
        shortestPathFinder.calculate();
    }
View Full Code Here

TOP

Related Classes of org.geotools.graph.path.DijkstraShortestPathFinder

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.