|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.base.Node
public class Node
Represents a so-called node in the directed graph data type Graph
.
Most notably, a node provides access to its adjacent edges (represented by instances
of class Edge
).
These can be distinguished into the sets of incoming and outgoing edges.
edges()
,
inEdges()
, outEdges()
).
Also supported is iteration over all nodes at opposite ends of either incoming
edges or outgoing edges (predecessors()
, successors()
).
The number of overall edges at a node is called its degree (degree()
),
which is the sum of incoming and outgoing edges (inDegree()
,
outDegree()
).
Important:
Class Graph is the single authority for any structural changes to the graph data
type.
Specifically, this means that there is no way to create or delete a node or an
edge without using an actual Graph instance.
Constructor Summary | |
---|---|
protected |
Node(Graph g)
Instantiates a new Node object that will be part of the given graph. |
Method Summary | |
---|---|
Node |
createCopy(Graph g)
Creates a copy of this node that will be inserted into the given graph. |
int |
degree()
Returns the overall number of incoming and outgoing edges at this node. |
EdgeCursor |
edges()
Returns an edge cursor for all incoming and outgoing edges at this node. |
Edge |
firstInEdge()
Returns the first incoming edge at this node, or null if it does
not exist. |
Edge |
firstOutEdge()
Returns the first outgoing edge at this node, or null if it does
not exist. |
Edge |
getEdge(Node opposite)
Returns an edge that connects this node with the given node, if such an edge exists. |
Edge |
getEdgeFrom(Node source)
Returns an incoming edge that connects the given node with this node, if such an edge exists. |
Edge |
getEdgeTo(Node target)
Returns an outgoing edge that connects this node with the given node, if such an edge exists. |
Graph |
getGraph()
Returns the graph this node belongs to. |
int |
inDegree()
Returns the number of incoming edges at this node. |
int |
index()
Returns the index of this node within its graph G. |
EdgeCursor |
inEdges()
Returns an edge cursor for all incoming edges at this node. |
EdgeCursor |
inEdges(Edge startEdge)
Returns an edge cursor for incoming edges at this node. |
Edge |
lastInEdge()
Returns the last incoming edge at this node, or null if it does
not exist. |
Edge |
lastOutEdge()
Returns the last outgoing edge at this node, or null if it does
not exist. |
NodeCursor |
neighbors()
Returns a node cursor for all neighbor nodes of this node. |
int |
outDegree()
Returns the number of outgoing edges at this node. |
EdgeCursor |
outEdges()
Returns an edge cursor for all outgoing edges at this node. |
EdgeCursor |
outEdges(Edge startEdge)
Returns an edge cursor for outgoing edges at this node. |
NodeCursor |
predecessors()
Returns a node cursor for all predecessor nodes of this node. |
void |
sortInEdges(java.util.Comparator c)
Sorts incoming edges at this node according to the given comparator. |
void |
sortOutEdges(java.util.Comparator c)
Sorts outgoing edges at this node according to the given comparator. |
NodeCursor |
successors()
Returns a node cursor for all successor nodes of this node. |
java.lang.String |
toString()
Returns a String representation of this node. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected Node(Graph g)
g
- The graph that the created node will belong to.Method Detail |
---|
public Node createCopy(Graph g)
g
- The graph that the created node will belong to.
public int degree()
Edge
,
inDegree()
,
outDegree()
public int inDegree()
degree()
,
outDegree()
public int outDegree()
degree()
,
inDegree()
public int index()
>= 0
and < G.nodeCount()
.
Note that indices are subject to change whenever the sequence of nodes in a
graph is modified by either removing, hiding, reinserting, or unhiding a node,
or by explicitly changing its position in the sequence.
Graph.removeNode(Node)
,
Graph.hide(Node)
,
Graph.reInsertNode(Node)
,
Graph.unhide(Node)
,
Graph.moveToFirst(Node)
,
Graph.moveToLast(Node)
public Graph getGraph()
null
.
public Edge firstOutEdge()
null
if it does
not exist.
firstInEdge()
,
lastOutEdge()
public Edge firstInEdge()
null
if it does
not exist.
firstOutEdge()
,
lastInEdge()
public Edge lastOutEdge()
null
if it does
not exist.
firstOutEdge()
,
lastInEdge()
public Edge lastInEdge()
null
if it does
not exist.
firstInEdge()
,
lastOutEdge()
public EdgeCursor edges()
inEdges()
,
outEdges()
public EdgeCursor inEdges()
edges()
,
outEdges()
public EdgeCursor inEdges(Edge startEdge)
inEdges()
.
startEdge
is an incoming edge at this node.startEdge
- The first edge being accessed by the returned cursor.outEdges(Edge)
public EdgeCursor outEdges()
edges()
,
inEdges()
public EdgeCursor outEdges(Edge startEdge)
outEdges()
.
startEdge
is an outgoing edge at this node.startEdge
- The first edge being accessed by the returned cursor.inEdges(Edge)
public NodeCursor neighbors()
predecessors()
,
successors()
public NodeCursor predecessors()
successors()
public NodeCursor successors()
predecessors()
public Edge getEdgeTo(Node target)
null
is returned.
getEdge(Node)
,
getEdgeFrom(Node)
public Edge getEdgeFrom(Node source)
null
is returned.
getEdge(Node)
,
getEdgeTo(Node)
public Edge getEdge(Node opposite)
null
is returned.
Note that the first matching edge is returned, and that outgoing edges are
tested prior to incoming edges.
getEdgeFrom(Node)
,
getEdgeTo(Node)
public void sortInEdges(java.util.Comparator c)
sortOutEdges(Comparator)
public void sortOutEdges(java.util.Comparator c)
sortInEdges(Comparator)
public java.lang.String toString()
toString
in class java.lang.Object
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |