001: package prefuse.data;
002:
003: import java.util.Iterator;
004:
005: /**
006: * Tuple sub-interface that represents a node in a graph or tree structure.
007: * This interface supports both graph and tree methods, tree methods invoked
008: * on a node in a general graph typically default to operations on the
009: * graph's generated spanning tree.
010: *
011: * @author <a href="http://jheer.org">jeffrey heer</a>
012: */
013: public interface Node extends Tuple {
014:
015: /**
016: * Get the Graph of which this Node is a member.
017: * @return the backing Graph.
018: */
019: public Graph getGraph();
020:
021: // ------------------------------------------------------------------------
022: // Graph Methods
023:
024: /**
025: * Get the in-degree of the node, the number of edges for which this node
026: * is the target.
027: * @return the in-degree of the node
028: */
029: public int getInDegree();
030:
031: /**
032: * Get the out-degree of the node, the number of edges for which this node
033: * is the source.
034: * @return the out-degree of the node
035: */
036: public int getOutDegree();
037:
038: /**
039: * Get the degree of the node, the number of edges for which this node
040: * is either the source or the target.
041: * @return the total degree of the node
042: */
043: public int getDegree();
044:
045: /**
046: * Get an iterator over all incoming edges, those for which this node
047: * is the target.
048: * @return an Iterator over all incoming edges
049: */
050: public Iterator inEdges();
051:
052: /**
053: * Get an iterator over all outgoing edges, those for which this node
054: * is the source.
055: * @return an Iterator over all outgoing edges
056: */
057: public Iterator outEdges();
058:
059: /**
060: * Get an iterator over all incident edges, those for which this node
061: * is either the source or the target.
062: * @return an Iterator over all incident edges
063: */
064: public Iterator edges();
065:
066: /**
067: * Get an iterator over all adjacent nodes connected to this node by an
068: * incoming edge (i.e., all nodes that "point" at this one).
069: * @return an Iterator over all neighbors with in-links on this node
070: */
071: public Iterator inNeighbors();
072:
073: /**
074: * Get an iterator over all adjacent nodes connected to this node by an
075: * outgoing edge (i.e., all nodes "pointed" to by this one).
076: * @return an Iterator over all neighbors with out-links from this node
077: */
078: public Iterator outNeighbors();
079:
080: /**
081: * Get an iterator over all nodes connected to this node.
082: * @return an Iterator over all neighbors of this node
083: */
084: public Iterator neighbors();
085:
086: // ------------------------------------------------------------------------
087: // Tree Methods
088:
089: /**
090: * Get the parent node of this node in a tree structure.
091: * @return this node's parent node, or null if there is none.
092: */
093: public Node getParent();
094:
095: /**
096: * Get the edge between this node and its parent node in a tree
097: * structure.
098: * @return the edge between this node and its parent
099: */
100: public Edge getParentEdge();
101:
102: /**
103: * Get the tree depth of this node.
104: * @return the tree depth of this node. The root's tree depth is
105: * zero, and each level of the tree is one depth level greater.
106: */
107: public int getDepth();
108:
109: /**
110: * Get the number of tree children of this node.
111: * @return the number of child nodes
112: */
113: public int getChildCount();
114:
115: /**
116: * Get the ordering index of the give node child in a tree
117: * structure.
118: * @param child the child node to look up
119: * @return the index of the child node, or -1 if the node is
120: * not a child of this one.
121: */
122: public int getChildIndex(Node child);
123:
124: /**
125: * Get the tree child node at the given index.
126: * @param idx the ordering index
127: * @return the child node at the given index
128: */
129: public Node getChild(int idx);
130:
131: /**
132: * Get this node's first tree child. This is the
133: * same as looking up the node at index 0.
134: * @return this node's first child node
135: */
136: public Node getFirstChild();
137:
138: /**
139: * Get this node's last tree child. This is the
140: * same as looking up the node at the child count
141: * minus 1.
142: * @return this node's last child node
143: */
144: public Node getLastChild();
145:
146: /**
147: * Get this node's previous tree sibling.
148: * @return the previous sibling, or null if none
149: */
150: public Node getPreviousSibling();
151:
152: /**
153: * Get this node's next tree sibling.
154: * @return the next sibling, or null if none
155: */
156: public Node getNextSibling();
157:
158: /**
159: * Get an iterator over this node's tree children.
160: * @return an iterator over this node's children
161: */
162: public Iterator children();
163:
164: /**
165: * Get an iterator over the edges from this node to its tree children.
166: * @return an iterator over the edges to the child nodes
167: */
168: public Iterator childEdges();
169:
170: } // end of interface Node
|