Packagecom.yworks.yfiles.base
Classpublic class Node
InheritanceNode Inheritance com.yworks.yfiles.base.GraphObject

Represents a so-called node in the directed graph data type com.yworks.yfiles.base.Graph. Most notably, a node provides access to its adjacent edges (represented by instances of class com.yworks.yfiles.base.Edge). These can be distinguished into the sets of incoming and outgoing edges.

Iteration over all three sets of edges is provided by means of bidirectional cursors that present a read-only view of the respective set ( 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.

See also

com.yworks.yfiles.base.Graph
com.yworks.yfiles.base.Edge
edges()
inEdges()
outEdges()
predecessors()
successors()
degree()
inDegree()
outDegree()


Public Properties
 PropertyDefined By
  graph : Graph
[read-only] Returns the graph this node belongs to.
Node
Public Methods
 MethodDefined By
  
Node(g:Graph, init:Boolean = true)
Instantiates a new Node object that will be part of the given graph.
Node
  
Creates a copy of this node that will be inserted into the given graph.
Node
  
degree():int
Returns the overall number of incoming and outgoing edges at this node.
Node
  
Returns an edge cursor for all incoming and outgoing edges at this node.
Node
  
Returns the first incoming edge at this node, or null if it does not exist.
Node
  
Returns the first outgoing edge at this node, or null if it does not exist.
Node
  
getClass():Class
[override]
Node
  
getEdge(opposite:Node):Edge
Returns an edge that connects this node with the given node, if such an edge exists.
Node
  
Returns an incoming edge that connects the given node with this node, if such an edge exists.
Node
  
Returns an outgoing edge that connects this node with the given node, if such an edge exists.
Node
  
inDegree():int
Returns the number of incoming edges at this node.
Node
  
index():int
Returns the index of this node within its graph G.
Node
  
Returns an edge cursor for all incoming edges at this node.
Node
  
Returns an edge cursor for incoming edges at this node.
Node
  
Returns the last incoming edge at this node, or null if it does not exist.
Node
  
Returns the last outgoing edge at this node, or null if it does not exist.
Node
  
Returns a node cursor for all neighbor nodes of this node.
Node
  
outDegree():int
Returns the number of outgoing edges at this node.
Node
  
Returns an edge cursor for all outgoing edges at this node.
Node
  
Returns an edge cursor for outgoing edges at this node.
Node
  
Returns a node cursor for all predecessor nodes of this node.
Node
  
Sorts incoming edges at this node according to the given comparator.
Node
  
Sorts outgoing edges at this node according to the given comparator.
Node
  
Returns a node cursor for all successor nodes of this node.
Node
  
toString():String
Returns a String representation of this node.
Node
Protected Methods
 MethodDefined By
  
Initializes this object.
Node
  
[static] Instantiates a new Node object that will be part of the given graph.
Node
Property Detail
graphproperty
graph:Graph  [read-only]

Returns the graph this node belongs to. If the node does not belong to a graph, because it was removed or hidden from it, this method returns null.


Implementation
    public function get graph():Graph
Constructor Detail
Node()Constructor
public function Node(g:Graph, init:Boolean = true)

Instantiates a new Node object that will be part of the given graph.

Parameters
g:Graph — The graph that the created node will belong to.
 
init:Boolean (default = true) — An internally used switch to help handle proper instance initialization in inheritance chains where classes can have multiple constructor-like factory methods. This parameter can safely be ignored/omitted when calling the constructor.
Method Detail
createCopy()method
public function createCopy(g:Graph):Node

Creates a copy of this node that will be inserted into the given graph.

Parameters

g:Graph — The graph that the created node will belong to.

Returns
Node — The newly created Node object.
degree()method 
public function degree():int

Returns the overall number of incoming and outgoing edges at this node.

Note that self-loops are counted twice.

Returns
int

See also

edges()method 
public function edges():EdgeCursor

Returns an edge cursor for all incoming and outgoing edges at this node.

Returns
EdgeCursor

See also

firstInEdge()method 
public function firstInEdge():Edge

Returns the first incoming edge at this node, or null if it does not exist.

Returns
Edge

See also

firstOutEdge()method 
public function firstOutEdge():Edge

Returns the first outgoing edge at this node, or null if it does not exist.

Returns
Edge

See also

getClass()method 
override public function getClass():Class

Returns
Class
getEdge()method 
public function getEdge(opposite:Node):Edge

Returns an edge that connects this node with the given node, if such an edge exists. Otherwise null is returned.

Note that the first matching edge is returned, and that outgoing edges are tested prior to incoming edges.

Parameters

opposite:Node

Returns
Edge

See also

getEdgeFrom()method 
public function getEdgeFrom(source:Node):Edge

Returns an incoming edge that connects the given node with this node, if such an edge exists. Otherwise null is returned.

Parameters

source:Node

Returns
Edge

See also

getEdgeTo()method 
public function getEdgeTo(target:Node):Edge

Returns an outgoing edge that connects this node with the given node, if such an edge exists. Otherwise null is returned.

Parameters

target:Node

Returns
Edge

See also

inDegree()method 
public function inDegree():int

Returns the number of incoming edges at this node.

Returns
int

See also

index()method 
public function index():int

Returns the index of this node within its graph G. Node indices represent the ordering of standard node iteration on G. The value of an index is >= 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.

Precondition This node must belong to some graph.

Returns
int

See also

inEdges()method 
public function inEdges():EdgeCursor

Returns an edge cursor for all incoming edges at this node.

Returns
EdgeCursor

See also

inEdgesFrom()method 
public function inEdgesFrom(startEdge:Edge):EdgeCursor

Returns an edge cursor for incoming edges at this node. The cursor starts at the given edge, and the cyclic sequence order is the same as returned by inEdges() .

Precondition startEdge is an incoming edge at this node.

Parameters

startEdge:Edge — The first edge being accessed by the returned cursor.

Returns
EdgeCursor

See also

initNode1()method 
protected final function initNode1(g:Graph):void

Initializes this object. See the documentation of the corresponding factory method newNode1() for details.

Parameters

g:Graph

See also

lastInEdge()method 
public function lastInEdge():Edge

Returns the last incoming edge at this node, or null if it does not exist.

Returns
Edge

See also

lastOutEdge()method 
public function lastOutEdge():Edge

Returns the last outgoing edge at this node, or null if it does not exist.

Returns
Edge

See also

neighbors()method 
public function neighbors():NodeCursor

Returns a node cursor for all neighbor nodes of this node. Neighbor nodes are those at the opposite ends of both incoming and outgoing edges.

Returns
NodeCursor

See also

newNode1()method 
protected static function newNode1(g:Graph):Node

Instantiates a new Node object that will be part of the given graph.

Parameters

g:Graph — The graph that the created node will belong to.

Returns
Node
outDegree()method 
public function outDegree():int

Returns the number of outgoing edges at this node.

Returns
int

See also

outEdges()method 
public function outEdges():EdgeCursor

Returns an edge cursor for all outgoing edges at this node.

Returns
EdgeCursor

See also

outEdgesFrom()method 
public function outEdgesFrom(startEdge:Edge):EdgeCursor

Returns an edge cursor for outgoing edges at this node. The cursor starts at the given edge, and the cyclic sequence order is the same as returned by outEdges() .

Precondition startEdge is an outgoing edge at this node.

Parameters

startEdge:Edge — The first edge being accessed by the returned cursor.

Returns
EdgeCursor

See also

predecessors()method 
public function predecessors():NodeCursor

Returns a node cursor for all predecessor nodes of this node. Predecessor nodes are those at the opposite ends of incoming edges.

Returns
NodeCursor

See also

sortInEdges()method 
public function sortInEdges(c:Comparator):void

Sorts incoming edges at this node according to the given comparator.

Parameters

c:Comparator

See also

sortOutEdges()method 
public function sortOutEdges(c:Comparator):void

Sorts outgoing edges at this node according to the given comparator.

Parameters

c:Comparator

See also

successors()method 
public function successors():NodeCursor

Returns a node cursor for all successor nodes of this node. Successor nodes are those at the opposite ends of outgoing edges.

Returns
NodeCursor

See also

toString()method 
public function toString():String

Returns a String representation of this node.

Returns
String