Package org.geotools.graph.structure

Examples of org.geotools.graph.structure.GraphVisitor


    * <BR>
    * Expected: 1. All nodes visited.
    */
   public void test_6() {
     GraphTestUtil.buildCircular(builder(), 100);
     GraphVisitor visitor = new GraphVisitor() {
        public int visit(Graphable component) {
          if (component.getID() == 50) return(Graph.PASS_AND_CONTINUE);
          return(Graph.FAIL_QUERY)
        }
     };
     Node source = (Node)builder().getGraph().queryNodes(visitor).get(0);
    
     CountingWalker walker = new CountingWalker();
     BreadthFirstIterator 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());
         return(0);
       }
     };
View Full Code Here


    m_maxplen = maxplen;
  }
 
  public Path getPath(Node from, Node to) {
       final Node dst = to;
       GraphVisitor visitor = new GraphVisitor() {
         public int visit(Graphable component) {
         if (component.equals(dst)) return(END_PATH_AND_STOP);
         return(CONTINUE_PATH);
         }
       };
View Full Code Here

       return((Path)paths.get(0));
  }
 
  public List getPaths(Node from, Node to) {
    final Node dst = to;
    GraphVisitor visitor = new GraphVisitor() {
      public int visit(Graphable component) {
      if (component.equals(dst)) return(END_PATH_AND_CONTINUE);
      return(CONTINUE_PATH);
    }
    };
View Full Code Here

    public List getNodesOfDegree(int n) {
      final int degree = n;

      return (
        queryNodes(
          new GraphVisitor() {
            public int visit(Graphable component) {
              if (((Node) component).getDegree() == degree)
                return (PASS_AND_CONTINUE);
              return (FAIL_QUERY);
            }
View Full Code Here

    private List getVisited(Collection components, boolean visited) {
      final boolean isVisited = visited;
      return (
        query(
          components,
          new GraphVisitor() {
            public int visit(Graphable component) {
              if (component.isVisited() == isVisited)
                return (PASS_AND_CONTINUE);
              return (FAIL_QUERY);
            }
View Full Code Here

    //create queue
    m_queue = buildQueue(graph);
   
    //initialize nodes
    graph.visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          DirectedNode node = (DirectedNode)component;
         
          node.setVisited(false);
          node.setCount(0);
View Full Code Here

    //create queue
    m_queue = buildQueue(graph);
   
    //initialize nodes
    graph.visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          Node node = (Node)component;
         
          //reset counter to zero
          node.setCount(0);
View Full Code Here

    queue = new PriorityQueue(comparator);
    queue.init(graph.getNodes().size());
   
    //place nodes into priority queue
    graph.visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          //create a dijkstra node with infinite cost
          DijkstraNode dn = new DijkstraNode((Node)component, Double.MAX_VALUE);
         
          //create the mapping
View Full Code Here

   * @see GraphTraversal#init()
   */
  public void init() {
    //initialize the nodes of the graph
    m_graph.visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          component.setVisited(false);
          component.setCount(0);
          return(0);
        }
View Full Code Here

  }
 
  public void init() {
    //initialize the nodes of the graph by setting counts to 0
    getGraph().visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          component.setCount(0);
          return(0);
        }
      }
View Full Code Here

TOP

Related Classes of org.geotools.graph.structure.GraphVisitor

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.