Packagecom.yworks.yfiles.base
Classpublic class Graph
InheritanceGraph Inheritance YObject Inheritance Object
Implements GraphInterface
Subclasses LayoutGraph

This class implements a directed graph structure. Basically, a directed graph consists of a set of objects called "nodes" (represented by instances of class com.yworks.yfiles.base.Node) and a set of node pairs which are called "edges" (represented by instances of class com.yworks.yfiles.base.Edge). The directed stems from the fact that all edges in the graph have direction, i.e., they have a distinct source node and a distinct target node. Using the aforementioned pair notation, an edge would be written as (<source node>, <target node>).

Class Graph presents a proper data type that provides support for all essential operations like element creation, removal, access, and iteration. 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.

Furthermore, this class is also responsible for providing access to its elements. This is done by means of bidirectional cursors that present a read-only view on the node set (interface com.yworks.yfiles.base.NodeCursor) and edge set (interface com.yworks.yfiles.base.EdgeCursor).

Class Graph fires notification events that signal structural changes, like, e.g., creation, removal, reinsertion, or modification of graph elements. Classes that implement the com.yworks.yfiles.base.GraphListener interface can be registered with this class using the addGraphListener (addGraphListener()) method in order to receive such events.

This class provides direct support for the notion of data accessors. It allows to register so-called data providers (implementations of interface com.yworks.yfiles.base.DataProvider) that hold arbitrary data which is associated to its nodes and/or edges. Also, it serves as a factory to create so-called maps ( com.yworks.yfiles.base.NodeMap, com.yworks.yfiles.base.EdgeMap) that can be utilized to bind arbitrary data to nodes and edges.

See also

com.yworks.yfiles.base.Node
com.yworks.yfiles.base.Edge
com.yworks.yfiles.base.NodeCursor
com.yworks.yfiles.base.EdgeCursor
com.yworks.yfiles.base.GraphListener
addGraphListener
com.yworks.yfiles.base.DataProvider
com.yworks.yfiles.base.NodeMap
com.yworks.yfiles.base.EdgeMap


Public Properties
 PropertyDefined By
  dataProviderKeys : Vector.<Object>
[read-only] Returns an array of all data provider look-up keys that are registered with this graph.
Graph
  empty : Boolean
[read-only] Returns true if this graph contains no nodes.
Graph
  graphCopyFactory : GraphCopier_CopyFactory
Specifies the copy factory that is associated with this instance.
Graph
  graphListeners : Iterator
[read-only] Returns an iterator that grants access to all registered graph listeners.
Graph
  registeredEdgeMaps : Vector.<Object>
[read-only] Returns all edge maps that have been created by this graph but have not yet been disposed.
Graph
  registeredNodeMaps : Vector.<Object>
[read-only] Returns all node maps that have been created by this graph but have not yet been disposed.
Graph
Public Methods
 MethodDefined By
  
Graph(init:Boolean = true)
Instantiates an empty Graph object.
Graph
  
addDataProvider(providerKey:Object, data:DataProvider):void
Registers the given data provider using the given look-up key.
Graph
  
Registers the given graph listener with this graph.
Graph
  
changeEdgeTo(e:Edge, e1:Edge, e2:Edge, d1:int, d2:int):void
Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
Graph
  
clear():void
Removes all nodes and edges from this graph and fires corresponding notification events to inform registered listeners.
Graph
  
containsEdge(e:Edge):Boolean
Whether or not this graph contains the given edge.
Graph
  
containsEdgeBetweenNodes(source:Node, target:Node):Boolean
Returns whether or not this graph contains an edge that connects the given nodes.
Graph
  
containsNode(v:Node):Boolean
Whether or not this graph contains the given node.
Graph
  
Creates a copy of this graph.
Graph
  
Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners.
Graph
  
createEdgeAt(v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):Edge
Creates a new edge in this graph to be ordered before or after a given edge and fires a corresponding notification event to inform registered listeners.
Graph
  
Returns a newly created edge map that is valid for the edges in this graph.
Graph
  
Creates an empty base object of the same type as this graph.
Graph
  
Creates a new node in this graph and fires a corresponding notification event to inform registered listeners.
Graph
  
Returns a newly created node map that is valid for the nodes in this graph.
Graph
  
Informs the graph that the given edge map is no longer needed.
Graph
  
Informs the graph that the given node map is no longer needed.
Graph
  
E():int
Returns the number of edges in this graph.
Graph
  
edgeCount():int
Returns the number of edges in this graph.
Graph
  
Returns an iterator that provides access to all edges residing in this graph.
Graph
  
Provides access to the edges of the graph.
Graph
 Inherited
equals(o:Object):Boolean
YObject
  
Propagates a so-called POST event to all registered graph listeners.
Graph
  
firePostEventWithId(id:Object):void
Like firePostEvent().
Graph
  
Propagates a so-called PRE event to all registered graph listeners.
Graph
  
firePreEventWithId(id:Object):void
Like firePreEvent().
Graph
  
Returns the first edge in this graph.
Graph
  
Returns the first node in this graph.
Graph
  
getClass():Class
[override]
Graph
  
getDataProvider(providerKey:Object):DataProvider
Returns the data provider that is registered with the graph using the given look-up key.
Graph
  
getEdgeArray():Vector.<Object>
Returns an array containing all edges of this graph.
Graph
  
getNodeArray():Vector.<Object>
Returns an array containing all nodes of this graph.
Graph
  
getSource(edge:Object):Object
Returns the source node associated with the given edge.
Graph
  
getTarget(edge:Object):Object
Returns the target node associated with the given edge.
Graph
 Inherited
hashCode():int
YObject
  
hideEdge(e:Edge):void
Hides the given edge from this graph.
Graph
  
hideNode(v:Node):void
Hides the given node from this graph.
Graph
  
Returns the last edge in this graph.
Graph
  
Returns the last node in this graph.
Graph
  
moveEdge(e:Edge, newSource:Node, newTarget:Node):void
Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
Graph
  
moveEdgeTo(e:Edge, newSource:Node, sourceReference:Edge, sourceD:int, newTarget:Node, targetReference:Edge, targetD:int):void
Redefines an edge's end points and fires corresponding notification events to inform registered listeners.
Graph
  
Moves the given edge to the first position within the sequence of edges in this graph.
Graph
  
Moves the given edge to the last position within the sequence of edges in this graph.
Graph
  
Moves the given node to the first position within the sequence of nodes in this graph.
Graph
  
Moves the given node to the last position within the sequence of nodes in this graph.
Graph
  
moveSubGraph(subNodes:NodeList, targetGraph:Graph):EdgeList
Moves an induced subgraph to another graph.
Graph
  
N():int
Returns the number of nodes in this graph.
Graph
  
[static] Instantiates an empty Graph object.
Graph
  
[static] Instantiates a new Graph object as a copy of the given graph.
Graph
  
newGraph3(graph:Graph, subNodes:YCursor):Graph
[static] Instantiates a new Graph object as a partial copy of the given graph.
Graph
  
nodeCount():int
Returns the number of nodes in this graph.
Graph
  
Returns an iterator that provides access to all nodes residing in this graph.
Graph
  
Provides access to the nodes of the graph.
Graph
  
For internal debugging purposes only.
Graph
  
Reinserts a formerly removed edge into this graph and fires a corresponding notification event to inform registered listeners.
Graph
  
Reinserts a formerly removed node into this graph and fires a corresponding notification event to inform registered listeners.
Graph
  
removeDataProvider(providerKey:Object):void
Removes the data provider that is registered using the given look-up key.
Graph
  
Removes the given edge from this graph and fires a corresponding notification event to inform registered listeners.
Graph
  
Removes the given graph listener from this graph.
Graph
  
Removes the given node from this graph.
Graph
  
Reverses the given edge and fires corresponding notification events to inform registered listeners.
Graph
  
sortEdges(inComp:Comparator, outComp:Comparator):void
Sorts incoming and outgoing edges at each node of the graph.
Graph
  
Sorts the internally held list of edges.
Graph
  
Sorts the internally held list of nodes.
Graph
  
toString():String
Returns a String representation of this graph.
Graph
  
Unhides the given edge in this graph.
Graph
  
Unhides the given node in this graph.
Graph
Protected Methods
 MethodDefined By
  
Factory method that is called by graphCopyFactory to create a (possibly shared) instance.
Graph
  
Propagates the given graph event to all registered graph listeners.
Graph
  
[static] Low-level iteration support for adjacent edges.
Graph
  
hasListeners():Boolean
Determines whether there are listeners registered with this instance.
Graph
  
initGraph1():void
Initializes this object.
Graph
  
initGraph2(argGraph:Graph):void
Initializes this object.
Graph
  
initGraph3(graph:Graph, subNodes:YCursor):void
Initializes this object.
Graph
Public Constants
 ConstantDefined By
  AFTER : int = 0
[static] Object insertion specifier.
Graph
  BEFORE : int = 1
[static] Object insertion specifier.
Graph
Property Detail
dataProviderKeysproperty
dataProviderKeys:Vector.<Object>  [read-only]

Returns an array of all data provider look-up keys that are registered with this graph.


Implementation
    public function get dataProviderKeys():Vector.<Object>
emptyproperty 
empty:Boolean  [read-only]

Returns true if this graph contains no nodes.


Implementation
    public function get empty():Boolean
graphCopyFactoryproperty 
graphCopyFactory:GraphCopier_CopyFactory

Specifies the copy factory that is associated with this instance. The factory should be used by software that wants to create copies of this graph instance if it is in need of a factory. If no factory has been set, this method will initialize this instance's factory using factory method createGraphCopyFactory().


Implementation
    public function get graphCopyFactory():GraphCopier_CopyFactory
    public function set graphCopyFactory(value:GraphCopier_CopyFactory):void

See also

graphListenersproperty 
graphListeners:Iterator  [read-only]

Returns an iterator that grants access to all registered graph listeners.


Implementation
    public function get graphListeners():Iterator
registeredEdgeMapsproperty 
registeredEdgeMaps:Vector.<Object>  [read-only]

Returns all edge maps that have been created by this graph but have not yet been disposed.


Implementation
    public function get registeredEdgeMaps():Vector.<Object>

See also

registeredNodeMapsproperty 
registeredNodeMaps:Vector.<Object>  [read-only]

Returns all node maps that have been created by this graph but have not yet been disposed.


Implementation
    public function get registeredNodeMaps():Vector.<Object>

See also

Constructor Detail
Graph()Constructor
public function Graph(init:Boolean = true)

Instantiates an empty Graph object.

Parameters
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
addDataProvider()method
public function addDataProvider(providerKey:Object, data:DataProvider):void

Registers the given data provider using the given look-up key. If there is already a data provider registered with that key, then it will be overwritten with the new one.

Parameters

providerKey:Object
 
data:DataProvider

addGraphListener()method 
public function addGraphListener(listener:GraphListener):void

Registers the given graph listener with this graph. The listener will receive graph events that signal structural changes occurring within this graph.

Parameters

listener:GraphListener

See also

changeEdgeTo()method 
public function changeEdgeTo(e:Edge, e1:Edge, e2:Edge, d1:int, d2:int):void

Redefines an edge's end points and fires corresponding notification events to inform registered listeners. Edge e has source node v := e1.source() and target node w := e2.target(). Edge e is inserted in such a way that an iteration over the edges at v returns e

and an iteration over the edges at w returns e

Precondition Edges e, e1, and e2 must belong to this graph.

Parameters

e:Edge — The edge to be changed.
 
e1:Edge — Reference edge for insertion at a new source node.
 
e2:Edge — Reference edge for insertion at a new target node.
 
d1:int — One of the object insertion specifiers BEFORE or AFTER .
 
d2:int — One of the object insertion specifiers BEFORE or AFTER .

See also

clear()method 
public function clear():void

Removes all nodes and edges from this graph and fires corresponding notification events to inform registered listeners.

containsEdge()method 
public function containsEdge(e:Edge):Boolean

Whether or not this graph contains the given edge.

Parameters

e:Edge

Returns
Boolean
containsEdgeBetweenNodes()method 
public function containsEdgeBetweenNodes(source:Node, target:Node):Boolean

Returns whether or not this graph contains an edge that connects the given nodes.

Parameters

source:Node — The source node.
 
target:Node — The target node.

Returns
Boolean

See also

containsNode()method 
public function containsNode(v:Node):Boolean

Whether or not this graph contains the given node.

Parameters

v:Node

Returns
Boolean
createCopy()method 
public function createCopy():Graph

Creates a copy of this graph. Invokes 2() .

Returns
Graph — The newly created Graph object.

See also

createEdge()method 
public function createEdge(v:Node, w:Node):Edge

Creates a new edge in this graph and fires a corresponding notification event to inform registered listeners. The new edge has source node v and target node w, i.e., would be written as edge e = (v, w).

The edge is appended to the lists of incoming and outgoing edges at the source node and target node, respectively.

Parameters

v:Node — The source node of the edge.
 
w:Node — The target node of the edge.

Returns
Edge — The newly created Edge object.
createEdgeAt()method 
public function createEdgeAt(v:Node, e1:Edge, w:Node, e2:Edge, d1:int, d2:int):Edge

Creates a new edge in this graph to be ordered before or after a given edge and fires a corresponding notification event to inform registered listeners. The new edge e has source node v and target node w, i.e., would be written as edge e = (v, w). Edge e is inserted in such a way that an iteration over the edges at node v returns e

and an iteration over the edges at w returns e

Precondition Edge e1 must have source node v and edge e2 must have target node w.

Parameters

v:Node — The source node of the edge.
 
e1:Edge — An edge with source node v.
 
w:Node — The target node of the edge.
 
e2:Edge — An edge with target node w.
 
d1:int — One of the object insertion specifiers BEFORE or AFTER .
 
d2:int — One of the object insertion specifiers BEFORE or AFTER .

Returns
Edge — The newly created Edge object.

See also

createEdgeMap()method 
public function createEdgeMap():EdgeMap

Returns a newly created edge map that is valid for the edges in this graph. The implementation returned by this method can be used for any edge that is part of this Graph instance at any point of time, i.e., it is safe to modify the graph structure (add and remove nodes and edges) freely.

The implementation returned uses O(m) memory at all times and provides true O(1) read and write access for each edge.

In order to release the resources held by this map, disposeEdgeMap() has to be called.

Returns
EdgeMap

See also

createGraph()method 
public function createGraph():Graph

Creates an empty base object of the same type as this graph.

Subclasses should override this method.

Returns
Graph
createGraphCopyFactory()method 
protected function createGraphCopyFactory():GraphCopier_CopyFactory

Factory method that is called by graphCopyFactory to create a (possibly shared) instance.

Returns
GraphCopier_CopyFactory — the (possibly shared) instance.

See also

createNode()method 
public function createNode():Node

Creates a new node in this graph and fires a corresponding notification event to inform registered listeners.

Returns
Node — The newly created Node object.
createNodeMap()method 
public function createNodeMap():NodeMap

Returns a newly created node map that is valid for the nodes in this graph. The implementation returned by this method can be used for any node that is part of this Graph instance at any point of time, i.e., it is safe to modify the graph structure (add and remove nodes and edges) freely.

The implementation returned uses O(n) memory at all times and provides true O(1) read and write access for each node.

In order to release the resources held by this map, disposeNodeMap() has to be called.

Returns
NodeMap

See also

disposeEdgeMap()method 
public function disposeEdgeMap(map:EdgeMap):void

Informs the graph that the given edge map is no longer needed. This method is used for EdgeMap implementations that have been obtained using the createEdgeMap() factory method.

Calling this method will destroy the edge map and associated resources can be freed. It is strongly recommended to dispose of all edge maps that are not needed anymore using this method.

Parameters

map:EdgeMap

See also

disposeNodeMap()method 
public function disposeNodeMap(map:NodeMap):void

Informs the graph that the given node map is no longer needed. This method is used for NodeMap implementations that have been obtained using the createNodeMap() factory method.

Calling this method will destroy the node map and associated resources can be freed. It is strongly recommended to dispose of all node maps that are not needed anymore using this method.

Parameters

map:NodeMap

See also

E()method 
public function E():int

Returns the number of edges in this graph. Same as edgeCount().

Returns
int — the number of edges in this graph.

See also

edgeCount()method 
public function edgeCount():int

Returns the number of edges in this graph.

Returns
int — the number of edges in this graph.
edgeObjects()method 
public function edgeObjects():Iterator

Returns an iterator that provides access to all edges residing in this graph.

Returns
Iterator
edges()method 
public function edges():EdgeCursor

Provides access to the edges of the graph.

Returns
EdgeCursor — An EdgeCursor to iterate over the edges in the graph.
fireGraphEvent()method 
protected function fireGraphEvent(e:GraphEvent):void

Propagates the given graph event to all registered graph listeners.

Parameters

e:GraphEvent

firePostEvent()method 
public function firePostEvent():void

Propagates a so-called POST event to all registered graph listeners. This method should only be used if a corresponding call to firePreEvent() was made.

Generally, PRE and POST events serve as a means to bracket a sequence of graph events.

See also

firePostEventWithId()method 
public function firePostEventWithId(id:Object):void

Like firePostEvent(). Additionally, an event ID may be specified.

Parameters

id:Object — An identifying tag for the event.

See also

firePreEvent()method 
public function firePreEvent():void

Propagates a so-called PRE event to all registered graph listeners. This method should only be used if a corresponding call to firePostEvent() follows.

Generally, PRE and POST events serve as a means to bracket a sequence of graph events.

See also

firePreEventWithId()method 
public function firePreEventWithId(id:Object):void

Like firePreEvent(). Additionally, an event ID may be specified.

Parameters

id:Object — An identifying tag for the event.

See also

firstEdge()method 
public function firstEdge():Edge

Returns the first edge in this graph.

Precondition edgeCount() > 0

Returns
Edge
firstNode()method 
public function firstNode():Node

Returns the first node in this graph.

Precondition !isEmpty()

Returns
Node
firstOutEdge()method 
protected static function firstOutEdge(v:Node):Edge

Low-level iteration support for adjacent edges.

Parameters

v:Node

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

Returns
Class
getDataProvider()method 
public function getDataProvider(providerKey:Object):DataProvider

Returns the data provider that is registered with the graph using the given look-up key. The look-up domain of a returned data provider normally consists of either the nodes of the graph, or its edges, or both.

Parameters

providerKey:Object

Returns
DataProvider
getEdgeArray()method 
public function getEdgeArray():Vector.<Object>

Returns an array containing all edges of this graph.

Returns
Vector.<Object>
getNodeArray()method 
public function getNodeArray():Vector.<Object>

Returns an array containing all nodes of this graph.

Returns
Vector.<Object>
getSource()method 
public function getSource(edge:Object):Object

Returns the source node associated with the given edge.

Parameters

edge:Object

Returns
Object
getTarget()method 
public function getTarget(edge:Object):Object

Returns the target node associated with the given edge.

Parameters

edge:Object

Returns
Object
hasListeners()method 
protected function hasListeners():Boolean

Determines whether there are listeners registered with this instance.

Returns
Boolean
hideEdge()method 
public function hideEdge(e:Edge):void

Hides the given edge from this graph. Hiding an edge means to (temporarily) remove the edge from the graph.

The only difference to a proper edge removal as performed by removeEdge() is that no com.yworks.yfiles.base.GraphEvent will be emitted that signals the structural change (i.e. the edge's removal).

Generally, hiding should only be used in the sense of temporarily removing an object that will be reinserted shortly after.

To reinsert a hidden edge use unhideEdge() .

Parameters

e:Edge

See also

hideNode()method 
public function hideNode(v:Node):void

Hides the given node from this graph. Hiding a node means to (temporarily) remove the node from the graph.

The only difference to a proper node removal as performed by removeNode() is that no com.yworks.yfiles.base.GraphEvent will be emitted that signals the structural change (i.e. the node's removal).

Generally, hiding should only be used in the sense of temporarily removing an object that will be reinserted shortly after.

To reinsert a hidden node use unhideNode() .

Parameters

v:Node

See also

initGraph1()method 
protected final function initGraph1():void

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

See also

initGraph2()method 
protected final function initGraph2(argGraph:Graph):void

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

Parameters

argGraph:Graph

See also

initGraph3()method 
protected final function initGraph3(graph:Graph, subNodes:YCursor):void

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

Parameters

graph:Graph
 
subNodes:YCursor

See also

lastEdge()method 
public function lastEdge():Edge

Returns the last edge in this graph.

Precondition edgeCount() > 0

Returns
Edge
lastNode()method 
public function lastNode():Node

Returns the last node in this graph.

Precondition !isEmpty()

Returns
Node
moveEdge()method 
public function moveEdge(e:Edge, newSource:Node, newTarget:Node):void

Redefines an edge's end points and fires corresponding notification events to inform registered listeners.

The edge is appended to the lists of incoming and outgoing edges at the given source node and target node, respectively.

Precondition newSource and newTarget must belong to this graph.

Parameters

e:Edge — The edge to be changed.
 
newSource:Node — The new source node of the given edge.
 
newTarget:Node — The new target node of the given edge.

moveEdgeTo()method 
public function moveEdgeTo(e:Edge, newSource:Node, sourceReference:Edge, sourceD:int, newTarget:Node, targetReference:Edge, targetD:int):void

Redefines an edge's end points and fires corresponding notification events to inform registered listeners. Edge e has source node v := sourceReference.source() or v := newSource, if sourceReference == null and target node w := targetReference.target() or w := newTarget, if targetReference == null. Edge e is inserted in such a way that an iteration over the edges at v returns e

and an iteration over the edges at w returns e

Precondition Edge e must belong to this graph. Also, either sourceReference or newSource must be non-null and belong to this graph, and either targetReference or newTarget must be non-null and belong to this graph.

Parameters

e:Edge — The edge to be changed.
 
newSource:Node — The new source node.
 
sourceReference:Edge — Reference edge for insertion at the new source node.
 
sourceD:int — One of the object insertion specifiers BEFORE or AFTER .
 
newTarget:Node — The new target node.
 
targetReference:Edge — Reference edge for insertion at the new target node.
 
targetD:int — One of the object insertion specifiers BEFORE or AFTER .

See also

moveEdgeToFirst()method 
public function moveEdgeToFirst(e:Edge):void

Moves the given edge to the first position within the sequence of edges in this graph.

Parameters

e:Edge

moveEdgeToLast()method 
public function moveEdgeToLast(e:Edge):void

Moves the given edge to the last position within the sequence of edges in this graph.

Parameters

e:Edge

moveNodeToFirst()method 
public function moveNodeToFirst(v:Node):void

Moves the given node to the first position within the sequence of nodes in this graph.

Parameters

v:Node

moveNodeToLast()method 
public function moveNodeToLast(v:Node):void

Moves the given node to the last position within the sequence of nodes in this graph.

Parameters

v:Node

moveSubGraph()method 
public function moveSubGraph(subNodes:NodeList, targetGraph:Graph):EdgeList

Moves an induced subgraph to another graph.

Precondition The nodes in subNodes must belong to this graph.

Parameters

subNodes:NodeList — A list of nodes that induce the subgraph to be moved.
 
targetGraph:Graph — The graph where the subgraph is moved to.

Returns
EdgeList — A list of removed edges that connected the induced subgraph to this graph.
N()method 
public function N():int

Returns the number of nodes in this graph. Same as nodeCount().

Returns
int — the number of nodes in this graph.

See also

newGraph1()method 
public static function newGraph1():Graph

Instantiates an empty Graph object.

Returns
Graph
newGraph2()method 
public static function newGraph2(argGraph:Graph):Graph

Instantiates a new Graph object as a copy of the given graph. Values bound to the argument graph via node and edge keys are available in the new Graph instance with the keys registered with argGraph. Only references to these values are copied.

The new Graph instance also inherits all graph listeners registered with the given graph.

This constructor does not use a com.yworks.yfiles.util.GraphCopier.

Parameters

argGraph:Graph — The graph to be copied.

Returns
Graph

See also

newGraph3()method 
public static function newGraph3(graph:Graph, subNodes:YCursor):Graph

Instantiates a new Graph object as a partial copy of the given graph. Only the subgraph induced by the given cursor will be copied to the new Graph instance. Values bound to the argument graph via node and edge keys are available in the new Graph instance with the keys registered with graph. Only references to these values are copied.

The new Graph instance also inherits all graph listeners registered with the given graph.

This constructor does not use a com.yworks.yfiles.util.GraphCopier.

Parameters

graph:Graph — The graph to be (partially) copied.
 
subNodes:YCursor — A cursor to iterate over the nodes that actually induce the subgraph to be copied.

Returns
Graph

See also

nodeCount()method 
public function nodeCount():int

Returns the number of nodes in this graph.

Returns
int — the number of nodes in this graph.
nodeObjects()method 
public function nodeObjects():Iterator

Returns an iterator that provides access to all nodes residing in this graph.

Returns
Iterator
nodes()method 
public function nodes():NodeCursor

Provides access to the nodes of the graph.

Returns
NodeCursor — A NodeCursor to iterate over the nodes in the graph.
printNodeSlotSize()method 
public function printNodeSlotSize():void

For internal debugging purposes only.

reInsertEdge()method 
public function reInsertEdge(e:Edge):void

Reinserts a formerly removed edge into this graph and fires a corresponding notification event to inform registered listeners.

The reinserted edge is appended to the sequence of edges in this graph, i.e., normally, its new position does not match the position before its removal. The same holds for the edge's positions in the list of incoming and outgoing edges at its source node and target node, respectively.

Parameters

e:Edge — The edge to be reinserted.

See also

reInsertNode()method 
public function reInsertNode(v:Node):void

Reinserts a formerly removed node into this graph and fires a corresponding notification event to inform registered listeners.

The reinserted node is appended to the sequence of nodes in this graph, i.e., normally, its new position does not match the position before its removal.

Parameters

v:Node — The node to be reinserted.

See also

removeDataProvider()method 
public function removeDataProvider(providerKey:Object):void

Removes the data provider that is registered using the given look-up key.

Parameters

providerKey:Object

removeEdge()method 
public function removeEdge(e:Edge):void

Removes the given edge from this graph and fires a corresponding notification event to inform registered listeners.

The edge will be deselected before it gets removed.

Parameters

e:Edge — The edge to be removed.

removeGraphListener()method 
public function removeGraphListener(listener:GraphListener):void

Removes the given graph listener from this graph.

Parameters

listener:GraphListener

removeNode()method 
public function removeNode(v:Node):void

Removes the given node from this graph. All edges connecting to the given node are removed as well (preceding the actual node removal). Corresponding notification events are fired to inform registered listeners.

The node will be deselected before it gets removed.

Parameters

v:Node — The node to be removed from this graph.

reverseEdge()method 
public function reverseEdge(e:Edge):void

Reverses the given edge and fires corresponding notification events to inform registered listeners. This operation exchanges source and target node of the edge.

Parameters

e:Edge

sortEdges()method 
public function sortEdges(inComp:Comparator, outComp:Comparator):void

Sorts incoming and outgoing edges at each node of the graph. If a given comparator is null, then the corresponding edges (i.e., incoming/outgoing) will not be sorted. This sorts the order of the edges as returned by com.yworks.yfiles.base.Node.outEdges() and com.yworks.yfiles.base.Node.inEdges() respectively.

Parameters

inComp:Comparator — The comparator used for the incoming edges at each node.
 
outComp:Comparator — The comparator used for the outgoing edges at each node.

See also

sortEdges2()method 
public function sortEdges2(comp:Comparator):void

Sorts the internally held list of edges. If the given comparator is null, then the edges will not be sorted. This list determines the order of the edges as returned by edges().

Parameters

comp:Comparator — The comparator used for the edges.

See also

sortNodes()method 
public function sortNodes(comp:Comparator):void

Sorts the internally held list of nodes. If the given comparator is null, then the nodes will not be sorted. This list determines the order of the nodes as returned by nodes().

Parameters

comp:Comparator — The comparator used for the nodes.

See also

toString()method 
public function toString():String

Returns a String representation of this graph. The result contains the String representations of all nodes followed by the String representations of all edges.

Returns
String
unhideEdge()method 
public function unhideEdge(e:Edge):void

Unhides the given edge in this graph. Unhiding an edge means to reinsert an edge that was formerly hidden from this graph by a call to hideEdge() .

The only difference to a proper edge reinsertion as performed by reInsertEdge() is that no com.yworks.yfiles.base.GraphEvent will be emitted that signals the structural change (i.e. the edge's reinsertion).

Parameters

e:Edge

See also

unhideNode()method 
public function unhideNode(v:Node):void

Unhides the given node in this graph. Unhiding a node means to reinsert a node that was formerly hidden from this graph by a call to hideNode() .

The only difference to a proper node reinsertion as performed by reInsertNode() is that no com.yworks.yfiles.base.GraphEvent will be emitted that signals the structural change (i.e. the node's reinsertion).

Parameters

v:Node

See also

Constant Detail
AFTERConstant
public static const AFTER:int = 0

Object insertion specifier. An object gets inserted after another one.

BEFOREConstant 
public static const BEFORE:int = 1

Object insertion specifier. An object gets inserted before another one.