/** * Get the Node tuple corresponding to the input node key field value. * The node key field is used to find the node id (node table row number), * which is then used to retrieve the Node tuple. * @param key a node key field value * @return the requested Node instance */ public Node getNodeFromKey(long key) { int n = getNodeIndex(key); return (n<0 ? null : getNode(n) ); }
/** * Returns a collection of all nodes of the graph. * @return all nodes of the graph */ public Collection<Node> getNodes() { Collection<Node> node = new ArrayList<Node>(); prefuse.util.collections.IntIterator it = graph.nodeRows(); while (it.hasNext()) { int currentId = (Integer) it.next(); if (this.graph.getNodeTable().isValidRow(currentId)) { node.add(new PrefuseObviousNode(this.graph.getNode(currentId))); } } return node; }
/** * Get the target Node for the given Edge instance. * @param e an Edge instance * @return the target Node of the edge */ public Node getTargetNode(Edge e) { edgeCheck(e, true); return getNode(getTargetNode(e.getRow())); }
Graph g = (Graph)getSourceData(pGroup); if ( t == g.getNodeTable() ) { return g.getNode(row); } else { return g.getEdge(row);
/** * Get the source Node for the given Edge instance. * @param e an Edge instance * @return the source Node of the edge */ public Node getSourceNode(Edge e) { edgeCheck(e, true); return getNode(getSourceNode(e.getRow())); }
/** * Given an Edge and an incident Node, return the other Node * connected to the edge. * @param e an Edge instance * @param n a Node instance. This node must * be connected to the edge * @return the adjacent Node */ public Node getAdjacentNode(Edge e, Node n) { edgeCheck(e, true); nodeCheck(n, true); return getNode(getAdjacentNode(e.getRow(), n.getRow())); }
/** * Gets the depth of the given node in the tree. * @param n a node of the tree * @return parent edge */ public int getDepth(Node n) { if (n.equals(this.getRoot())) { return 0; } else { int depth = 0; for (int i = n.getRow(); i != getRoot().getRow() && i >= 0; ++depth, i = getParentNode(new PrefuseObviousNode( getPrefuseGraph().getNode(i))).getRow()) { continue; } return depth; } }
n = g.getNode(row); else n = g.getEdge(row).getTargetNode();