KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > data > Node


1 package prefuse.data;
2
3 import java.util.Iterator JavaDoc;
4
5
6 /**
7  * Tuple sub-interface that represents a node in a graph or tree structure.
8  * This interface supports both graph and tree methods, tree methods invoked
9  * on a node in a general graph typically default to operations on the
10  * graph's generated spanning tree.
11  *
12  * @author <a HREF="http://jheer.org">jeffrey heer</a>
13  */

14 public interface Node extends Tuple {
15
16     /**
17      * Get the Graph of which this Node is a member.
18      * @return the backing Graph.
19      */

20     public Graph getGraph();
21
22     // ------------------------------------------------------------------------
23
// Graph Methods
24

25     /**
26      * Get the in-degree of the node, the number of edges for which this node
27      * is the target.
28      * @return the in-degree of the node
29      */

30     public int getInDegree();
31     
32     /**
33      * Get the out-degree of the node, the number of edges for which this node
34      * is the source.
35      * @return the out-degree of the node
36      */

37     public int getOutDegree();
38     
39     /**
40      * Get the degree of the node, the number of edges for which this node
41      * is either the source or the target.
42      * @return the total degree of the node
43      */

44     public int getDegree();
45     
46     /**
47      * Get an iterator over all incoming edges, those for which this node
48      * is the target.
49      * @return an Iterator over all incoming edges
50      */

51     public Iterator JavaDoc inEdges();
52     
53     /**
54      * Get an iterator over all outgoing edges, those for which this node
55      * is the source.
56      * @return an Iterator over all outgoing edges
57      */

58     public Iterator JavaDoc outEdges();
59     
60     /**
61      * Get an iterator over all incident edges, those for which this node
62      * is either the source or the target.
63      * @return an Iterator over all incident edges
64      */

65     public Iterator JavaDoc edges();
66     
67     /**
68      * Get an iterator over all adjacent nodes connected to this node by an
69      * incoming edge (i.e., all nodes that "point" at this one).
70      * @return an Iterator over all neighbors with in-links on this node
71      */

72     public Iterator JavaDoc inNeighbors();
73     
74     /**
75      * Get an iterator over all adjacent nodes connected to this node by an
76      * outgoing edge (i.e., all nodes "pointed" to by this one).
77      * @return an Iterator over all neighbors with out-links from this node
78      */

79     public Iterator JavaDoc outNeighbors();
80     
81     /**
82      * Get an iterator over all nodes connected to this node.
83      * @return an Iterator over all neighbors of this node
84      */

85     public Iterator JavaDoc neighbors();
86     
87     // ------------------------------------------------------------------------
88
// Tree Methods
89

90     /**
91      * Get the parent node of this node in a tree structure.
92      * @return this node's parent node, or null if there is none.
93      */

94     public Node getParent();
95     
96     /**
97      * Get the edge between this node and its parent node in a tree
98      * structure.
99      * @return the edge between this node and its parent
100      */

101     public Edge getParentEdge();
102     
103     /**
104      * Get the tree depth of this node.
105      * @return the tree depth of this node. The root's tree depth is
106      * zero, and each level of the tree is one depth level greater.
107      */

108     public int getDepth();
109     
110     /**
111      * Get the number of tree children of this node.
112      * @return the number of child nodes
113      */

114     public int getChildCount();
115     
116     /**
117      * Get the ordering index of the give node child in a tree
118      * structure.
119      * @param child the child node to look up
120      * @return the index of the child node, or -1 if the node is
121      * not a child of this one.
122      */

123     public int getChildIndex(Node child);
124     
125     /**
126      * Get the tree child node at the given index.
127      * @param idx the ordering index
128      * @return the child node at the given index
129      */

130     public Node getChild(int idx);
131     
132     /**
133      * Get this node's first tree child. This is the
134      * same as looking up the node at index 0.
135      * @return this node's first child node
136      */

137     public Node getFirstChild();
138     
139     /**
140      * Get this node's last tree child. This is the
141      * same as looking up the node at the child count
142      * minus 1.
143      * @return this node's last child node
144      */

145     public Node getLastChild();
146     
147     /**
148      * Get this node's previous tree sibling.
149      * @return the previous sibling, or null if none
150      */

151     public Node getPreviousSibling();
152     
153     /**
154      * Get this node's next tree sibling.
155      * @return the next sibling, or null if none
156      */

157     public Node getNextSibling();
158     
159     /**
160      * Get an iterator over this node's tree children.
161      * @return an iterator over this node's children
162      */

163     public Iterator JavaDoc children();
164     
165     /**
166      * Get an iterator over the edges from this node to its tree children.
167      * @return an iterator over the edges to the child nodes
168      */

169     public Iterator JavaDoc childEdges();
170     
171 } // end of interface Node
172
Popular Tags