Packageorg.un.flex.graphLayout.data
Interfacepublic interface IGraph
ImplementorsGraph

Interface to the Graph datastructure class that hold the set of nodes and edges that actually form that graph



Public Properties
 PropertyDefined by
  edges : Array
[read-only] An Array that contains all edges of the graph.
IGraph
  id : String
[read-only] The id (or name) of the graph
IGraph
  isDirectional : Boolean
[read-only] Indicator if the graph is directional or not.
IGraph
  nodes : Array
[read-only] An Array that contains all nodes of the graph.
IGraph
  nodeSortFunction : Function
Provide a method to sort nodes in a graph.
IGraph
  noEdges : int
[read-only] The number of edges in the graph.
IGraph
  noNodes : int
[read-only] The number of nodes in the graph.
IGraph
  walkingDirection : int
This determines the walking direction when building a spanning tree.
IGraph
Public Methods
 MethodDefined by
  
createNode(sid:String = "", o:Object = null):INode
Creates a graph node in the graph, optionally takes a string id for the node and an object to associate the node with.
IGraph
  
Find an edge between two nodes.
IGraph
  
getTree(n:INode, restr:Boolean = false, nocache:Boolean = false):IGTree
returns the current BFS tree of the graph, rooted in the given node, optionally the tree is restricted to only contain currently visible nodes.
IGraph
  
initFromXML(xml:XML, xmlnames:Array):void
Creates a graph from XML.
IGraph
  
link(node1:INode, node2:INode, o:Object = null):IEdge
Link two nodes together (i.e.
IGraph
  
nodeById(id:int):INode
A lookup to find a node by it's (int) id.
IGraph
  
nodeByStringId(sid:String):INode
A lookup to find a node by it's string id.
IGraph
  
purgeGraph():void
Remove all edges and nodes from the Graph.
IGraph
  
purgeTrees():void
Under certain circumstances all cached trees need to be purged.
IGraph
  
removeEdge(e:IEdge):void
Removes an edge between two nodes.
IGraph
  
removeNode(n:INode):void
Removes a node from the graph.
IGraph
  
unlink(node1:INode, node2:INode):void
Unlink two nodes, effectively removing the edge between them.
IGraph
Property detail
edgesproperty
edges:Array  [read-only]

An Array that contains all edges of the graph.

Implementation
    public function get edges():Array
idproperty 
id:String  [read-only]

The id (or name) of the graph

Implementation
    public function get id():String
isDirectionalproperty 
isDirectional:Boolean  [read-only]

Indicator if the graph is directional or not.

Implementation
    public function get isDirectional():Boolean
nodesproperty 
nodes:Array  [read-only]

An Array that contains all nodes of the graph.

Implementation
    public function get nodes():Array
nodeSortFunctionproperty 
nodeSortFunction:Function  [read-write]

Provide a method to sort nodes in a graph. This can be used by GTree when building a spanning tree. The function must be compatible with a function to sort an Array.

The default value is null.

Implementation
    public function get nodeSortFunction():Function
    public function set nodeSortFunction(value:Function):void

See also

Array
noEdgesproperty 
noEdges:int  [read-only]

The number of edges in the graph.

Implementation
    public function get noEdges():int
noNodesproperty 
noNodes:int  [read-only]

The number of nodes in the graph.

Implementation
    public function get noNodes():int
walkingDirectionproperty 
walkingDirection:int  [read-write]

This determines the walking direction when building a spanning tree. Possible values are Graph.WALK_FORWARD Graph.WALK_BACKWARDS Graph.WALK_BOTH All make only sense in a directional graph. Forward means we follow edges in its regular direction from the root node. Backwards means, we follow edges back from the root node (e.g. the root is a sink with multiple sources) Both obviously means both. This property will be queried by GTree to determine the walking direction set.

Implementation
    public function get walkingDirection():int
    public function set walkingDirection(value:int):void
Method detail
createNode()method
public function createNode(sid:String = "", o:Object = null):INode

Creates a graph node in the graph, optionally takes a string id for the node and an object to associate the node with.

Parameters
sid:String (default = "") — A unique string id for the node (if empty the numerical id will be used).
 
o:Object (default = null) — Dataobject to be associated with this node.

Returns
INode — The created node object.

Throws
— if the string id was already used before (must be unique).
getEdge()method 
public function getEdge(n1:INode, n2:INode):IEdge

Find an edge between two nodes.

Parameters
n1:INode — The first node of the edge.
 
n2:INode — The second node of the edge.

Returns
IEdge — The resulting edge or null if the nodes were not linked.
getTree()method 
public function getTree(n:INode, restr:Boolean = false, nocache:Boolean = false):IGTree

returns the current BFS tree of the graph, rooted in the given node, optionally the tree is restricted to only contain currently visible nodes. The trees are cached, that means a tree is only created once and then stored in a map, unless the "nocache" flag is set! If the flag is set, then the tree will be created once and returned, the existing cache will not be touched or overwritten, this is useful if a full tree is needed for a specific purpose but the cache should not be overwritten or consulted.

Parameters
n:INode — The root node of the tree.
 
restr:Boolean (default = false) — This flag specifies if the resulting tree should be restricted to currently visible nodes.
 
nocache:Boolean (default = false) — If set, always a new tree will be created and returned and the cache will be untouched.

Returns
IGTree — The a GTree object that contains the tree.
initFromXML()method 
public function initFromXML(xml:XML, xmlnames:Array):void

Creates a graph from XML. The XML you provide should contain 2 kinds of elements
<Node id="xxx" anything-else..../>
and
<Edge fromID="xxx" toID="yyy"/>

You can have additional tags, and/or nest the tags any way you like; this will not have any effect. We create a graph where each Item corresponds to a single node. The item's id will come from the Node's id attribute (make sure this is unique). The item's data will be the Node, and will be of type XML. The <Edge> elements must come fterthe corresponding <Node> elements have appeared. The xmlnames array must have 4 elements:

Parameters
xml:XML — an XML document containing Node and Edge elements.
 
xmlnames:Array — the XML element and attribute names to use when parsing an XML dataProvider.
link()method 
public function link(node1:INode, node2:INode, o:Object = null):IEdge

Link two nodes together (i.e. create an edge). If the graph is NOT directional the same edge will be incoming and outgoing for both nodes. If the nodes are already linked, it will just return the existing edge between them.

Parameters
node1:INode — First node to be linked.
 
node2:INode — Second node to be linked.
 
o:Object (default = null) — Optional data object to be associated with the resulting edge.

Returns
IEdge — The resulting edge.

Throws
— if any node is null.
nodeById()method 
public function nodeById(id:int):INode

A lookup to find a node by it's (int) id.

Parameters
id:int — The node's id.

Returns
INode — The node if one was found, null otherwise.
nodeByStringId()method 
public function nodeByStringId(sid:String):INode

A lookup to find a node by it's string id.

Parameters
sid:String — The node's string id.

Returns
INode — The node if one was found, null otherwise.
purgeGraph()method 
public function purgeGraph():void

Remove all edges and nodes from the Graph.

purgeTrees()method 
public function purgeTrees():void

Under certain circumstances all cached trees need to be purged.

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

Removes an edge between two nodes.

Parameters
e:IEdge — The edge to be removed.

Throws
— error if the edge was not part of the graph.
removeNode()method 
public function removeNode(n:INode):void

Removes a node from the graph. If the node is part of any edge, and error is thrown (i.e. edges must be removed/nodes unlinked first).

Parameters
n:INode — The node object to be removed.

Throws
— error if the node is still part of any edge.
 
— error if the node to be removed cannot be found in the graph.
 
— error if there exists still a vnode associated with this node.
unlink()method 
public function unlink(node1:INode, node2:INode):void

Unlink two nodes, effectively removing the edge between them.

Parameters
node1:INode — The first node to be unlinked.
 
node2:INode — The second node to be unlinked.

Throws
— error if the nodes were not linked before.