Package org.geotools.graph.structure

Examples of org.geotools.graph.structure.Node


      objout.writeObject(e);
    }
   
    //write out any nodes that have no adjacent edges
    for (Iterator itr = graph.getNodesOfDegree(0).iterator(); itr.hasNext();) {
      Node n = (Node)itr.next();
      objout.writeObject(n);
    }
   
    objout.flush();
    objout.close();
View Full Code Here


     * @see BasicGraphable#isVisited()
     * @see BasicGraphable#getCount()
     */
    public void initNodes() {
      for (Iterator itr = m_nodes.iterator(); itr.hasNext();) {
        Node node = (Node) itr.next();
        node.setVisited(false);
        node.setCount(0);
      }
    }
View Full Code Here

        * in the opened queue.
        *
        * @see org.geotools.graph.traverse.GraphIterator#cont(Graphable)
        */
        public void cont(Graphable current, GraphTraversal traversal) {
                Node currdn = (Node) current;
                AStarNode currAsn;
                AStarNode nextAsn;


                currAsn = (AStarNode) m_nodemap.get(currdn);
                if (currAsn == null) {
                        throw new IllegalArgumentException("AStarIterator: The node is not in the open list");
                }
                currAsn.close();
                for (Iterator itr = currdn.getRelated(); itr.hasNext();) {
                        Node next = (Node) itr.next();
                        if (m_nodemap.containsKey(next)) {
                                nextAsn = (AStarNode) m_nodemap.get(next);
                                if(!nextAsn.isClosed()) {
                                        if ((currAsn.getG() + m_afuncs.cost(currAsn, nextAsn)) < nextAsn.getG()) {
                                                nextAsn.setG(currAsn.getG() + m_afuncs.cost(currAsn, nextAsn));
View Full Code Here

   
    //initialize nodes
    graph.visitNodes(
      new GraphVisitor() {
        public int visit(Graphable component) {
          Node node = (Node)component;
         
          //reset counter to zero
          node.setCount(0);
         
          if (node.getDegree() < 2) m_queue.enq(node);
         
          return(0)
        }
      }
    );   
View Full Code Here

   */
  public void cont(Graphable current, GraphTraversal traversal) {
    //increment the count of all adjacent nodes by one
    // if the result count is 1 less than the degree, place it into the queue
    for (Iterator itr = current.getRelated(); itr.hasNext();) {
      Node related = (Node)itr.next();
      if (!traversal.isVisited(related)) {
        related.setCount(related.getCount()+1)
        if (related.getDegree()-1 == related.getCount()) m_queue.enq(related);
     
    }
  }
View Full Code Here

   * @see GraphGenerator#add(Object)
   */
  public Graphable add(Object obj) {
    LineSegment line = (LineSegment)obj;
    Coordinate first,last;
    Node n1, n2;
   
    //check first coordinate
    first = line.p0;
    n1 = retrieveNode(first);
    if (n1 == null) {
View Full Code Here

   */
  public Graphable get(Object obj) {
    LineSegment line = (LineSegment)obj;
   
    //get nodes representing coordinate
    Node n1 = retrieveNode(line.p0);
    Node n2 = retrieveNode(line.p1);
   
    if (n1 == null || n2 == null) return(null);
   
    //return edge shared between them
    return(n1.getEdge(n2));
View Full Code Here

   *
   * @see GraphGenerator#remove(Object)
   */
  public Graphable remove(Object obj) {
    LineSegment line = (LineSegment)obj;
    Node n1 = retrieveNode(line.p0);
    Node n2 = retrieveNode(line.p1);
   
    if (n1 == null || n2 == null) return(null);
   
    Edge e = n1.getEdge(n2);
    getGraphBuilder().removeEdge(e);
View Full Code Here

  public Node getNode(Coordinate c) {
    return retrieveNode(c);
  }

  public Edge getEdge(Coordinate c1, Coordinate c2) {
    Node n1 = retrieveNode(c1);
    Node n2 = retrieveNode(c2);
   
    return(n1.getEdge(n2))
  }
View Full Code Here

  protected void setObject(Node n, Object obj) {
    n.setObject(obj);
  }

  private Node createNode(Coordinate c) {
    Node node;
    node = getGraphBuilder().buildNode();
    setObject(node, c);
    getGraphBuilder().addNode(node);
    m_coord2node.put(c, node);
    if (useTolerance()) {
View Full Code Here

TOP

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

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.