/** * Adds a node to the map, replacing any that is already at that location. * Only subclasses can add Nodes, to ensure Nodes are of the right type. * * @param node the node to add */ protected void add(Node node) { nodeMap.add(node); }
/** * Returns the {@link Node} at the given location, * or null if no {@link Node} was there. * * @param pt the location to query * @return the node found * or <code>null</code> if this graph contains no node at the location */ public Node findNode(Coordinate pt) { return (Node) nodeMap.find(pt); }
/** * Returns an {@link Iterator} over the {@link Node}s in this graph. * @return an iterator over the nodes */ public Iterator nodeIterator() { return nodeMap.iterator(); }
public Collection getNodes() { return nodeMap.values(); }
/** * Removes a node from the graph, along with any associated DirectedEdges and * Edges. */ public void remove(Node node) { // unhook all directed edges List outEdges = node.getOutEdges().getEdges(); for (Iterator i = outEdges.iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); DirectedEdge sym = de.getSym(); // remove the diredge that points to this node if (sym != null) remove(sym); // remove this diredge from the graph collection dirEdges.remove(de); Edge edge = de.getEdge(); if (edge != null) { edges.remove(edge); } } // remove the node from the graph nodeMap.remove(node.getCoordinate()); node.remove(); }
public Collection getNodes() { return nodeMap.values(); }
/** * Removes a node from the graph, along with any associated DirectedEdges and * Edges. */ public void remove(Node node) { // unhook all directed edges List outEdges = node.getOutEdges().getEdges(); for (Iterator i = outEdges.iterator(); i.hasNext(); ) { DirectedEdge de = (DirectedEdge) i.next(); DirectedEdge sym = de.getSym(); // remove the diredge that points to this node if (sym != null) remove(sym); // remove this diredge from the graph collection dirEdges.remove(de); Edge edge = de.getEdge(); if (edge != null) { edges.remove(edge); } } // remove the node from the graph nodeMap.remove(node.getCoordinate()); node.remove(); }
/** * Returns an Iterator over the Nodes in this PlanarGraph. */ public Iterator nodeIterator() { return nodeMap.iterator(); } /**
/** * Adds an {@link Edge} to the subgraph. * The associated {@link DirectedEdge}s and {@link Node}s * are also added. * * @param e the edge to add */ public void add(Edge e) { if (edges.contains(e)) return; edges.add(e); dirEdges.add(e.getDirEdge(0)); dirEdges.add(e.getDirEdge(1)); nodeMap.add(e.getDirEdge(0).getFromNode()); nodeMap.add(e.getDirEdge(1).getFromNode()); }
/** * Returns the {@link Node} at the given location, * or null if no {@link Node} was there. * * @param pt the location to query * @return the node found * or <code>null</code> if this graph contains no node at the location */ public Node findNode(Coordinate pt) { return (Node) nodeMap.find(pt); }
/** * Returns an Iterator over the Nodes in this PlanarGraph. */ public Iterator nodeIterator() { return nodeMap.iterator(); } /**
/** * Adds a node to the map, replacing any that is already at that location. * Only subclasses can add Nodes, to ensure Nodes are of the right type. * * @param node the node to add */ protected void add(Node node) { nodeMap.add(node); }
/** * Returns an {@link Iterator} over the {@link Node}s in this graph. * @return an iterator over the nodes */ public Iterator nodeIterator() { return nodeMap.iterator(); }
/** * Adds an {@link Edge} to the subgraph. * The associated {@link DirectedEdge}s and {@link Node}s * are also added. * * @param e the edge to add */ public void add(Edge e) { if (edges.contains(e)) return; edges.add(e); dirEdges.add(e.getDirEdge(0)); dirEdges.add(e.getDirEdge(1)); nodeMap.add(e.getDirEdge(0).getFromNode()); nodeMap.add(e.getDirEdge(1).getFromNode()); }