Examples of BasicGraphTraversal


Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

        return super.visit(element, traversal);
      }
    };
   
    BreadthFirstTopologicalIterator iterator = createIterator();
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator
    );
    traversal.init();
    traversal.traverse();
   
    assertTrue(walker.getCount() == nnodes);
   
    boolean flip = false;
    for (
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

      }
    };
   
    BreadthFirstTopologicalIterator iterator = createIterator();
   
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator  
    );
    traversal.init();
    traversal.traverse();
   
    //ensure that each node in lower level visited before node in higher level
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        String id = component.getObject().toString();
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

    GraphTestUtil.buildCircular(builder(), nnodes);
   
    CountingWalker walker = new CountingWalker();
    BreadthFirstTopologicalIterator iterator = createIterator();
   
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator
    )
    traversal.init();
    traversal.traverse();
   
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        assertTrue(!component.isVisited());
        return 0;
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

      }
    };
       
    DepthFirstIterator iterator = createIterator();
   
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator
    );
    traversal.init();
   
    iterator.setSource(ends[0]);
    traversal.traverse();
   
    //every node should have been visited
    assertTrue(walker.getCount() == builder().getGraph().getNodes().size());
   
    //ensure nodes visited only once
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

        return(GraphTraversal.CONTINUE);
      }
    };
   
    DepthFirstIterator iterator = createIterator();
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator
    );
    traversal.init();
   
    iterator.setSource(ends[0]);
    traversal.traverse();
   
    //stopping node should be visited and nodes with greater id should not
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        if (component.getID() <= suspend) assertTrue(component.isVisited());
        else assertTrue(!component.isVisited());
        return(0);
      }
    };
    builder().getGraph().visitNodes(visitor);
   
    //ensure nodes only visited once
    assertTrue(walker.getCount() == nnodes-suspend+1);
   
    traversal.traverse();
   
    //every node should now be visited
    visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        assertTrue(component.isVisited());  
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

        return(GraphTraversal.CONTINUE);
      }
    };
   
    DepthFirstIterator iterator = createIterator();
    BasicGraphTraversal traversal = new BasicGraphTraversal(
      builder().getGraph(), walker, iterator
    );
    traversal.init();
   
    iterator.setSource(ends[0]);
    traversal.traverse();
   
    //kill node should be visited and nodes with greater id should not
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        if (component.getID() <= kill) assertTrue(component.isVisited());
        else assertTrue(!component.isVisited());
        return(0);
      }
    };
    builder().getGraph().visitNodes(visitor);
   
    //ensure nodes only visited once
    assertTrue(walker.getCount() == nnodes-kill+1);
   
    //continue, no more nodes should be visited
    traversal.traverse();
 
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

        return super.visit(element, traversal);
      }
     };
    
     DepthFirstIterator iterator = createIterator();
     BasicGraphTraversal traversal = new BasicGraphTraversal(
       builder().getGraph(), walker, iterator
     );
     traversal.init();
    
     iterator.setSource(root);
     traversal.traverse();
    
     GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
        //ensure component visited
        assertTrue(component.isVisited());
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

         return(GraphTraversal.CONTINUE);
       }
     };
         
     DepthFirstIterator iterator = createIterator();
     BasicGraphTraversal traversal = new BasicGraphTraversal(
       builder().getGraph(), walker, iterator
     );
     traversal.init();
    
     iterator.setSource(root);
     traversal.traverse();
    
     //ensure that only root and one of children is visited
     assertTrue(root.isVisited());
     assertTrue(
       (rn.isVisited() && !ln.isVisited()) ||
       (!rn.isVisited() && ln.isVisited())
     );
     assertTrue(walker.getCount() == 2);
    
     GraphVisitor visitor = new GraphVisitor() {
       public int visit(Graphable component) {
         if (component != root && component != ln && component != rn) {
           assertTrue(!component.isVisited())
         }
         return(0);
       }
     };
     builder().getGraph().visitNodes(visitor);
    
     traversal.traverse();
    
     //ensure all nodes visited
     visitor = new GraphVisitor() {
       public int visit(Graphable component) {
         assertTrue(component.isVisited());
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

         return(GraphTraversal.CONTINUE);
       }
     };
         
     DepthFirstIterator iterator = createIterator();
     BasicGraphTraversal traversal = new BasicGraphTraversal(
       builder().getGraph(), walker, iterator
     );
     traversal.init();
    
     iterator.setSource(root);
     traversal.traverse();
    
     //ensure that subnodes of first visited after root are not visited
     final String id = (ln.getCount() < rn.getCount()) ?
                   ln.getObject().toString() :
                   rn.getObject().toString();
    
     GraphVisitor visitor = new GraphVisitor() {
       public int visit(Graphable component) {
         String eid = component.getObject().toString();
         if (eid.length() <= id.length()) assertTrue(component.isVisited());
         else if (eid.startsWith(id)) assertTrue(!component.isVisited());
         else assertTrue(component.isVisited());
        
         return(0);
       }
     };
     builder().getGraph().visitNodes(visitor);
     assertTrue(walker.getCount() == (int)Math.pow(2,k)+1);
    
     traversal.traverse();
    
     builder().getGraph().visitNodes(visitor);
     assertTrue(walker.getCount() == (int)Math.pow(2,k)+1);
   }
View Full Code Here

Examples of org.geotools.graph.traverse.basic.BasicGraphTraversal

     Node source = (Node)builder().getGraph().queryNodes(visitor).get(0);
    
     CountingWalker walker = new CountingWalker();
     DepthFirstIterator iterator = createIterator();
    
     BasicGraphTraversal traversal = new BasicGraphTraversal(
       builder().getGraph(), walker, iterator
     );
     traversal.init();
    
     iterator.setSource(source);
     traversal.traverse();
    
     //ensure all nodes visisited
     visitor = new GraphVisitor() {
       public int visit(Graphable component) {
         assertTrue(component.isVisited());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.