Packageorg.un.flex.graphLayout.data
Classpublic class GTree
ImplementsIGTree

This class represents a spanning tree, rooted in the given root node of the connected component of the associated graph.

It stores the predecessors of each node to allow the traversal and also the distance of each node to the root.



Public Properties
 PropertyDefined by
  distances : Dictionary
[read-only] The map that contains the distance for each node (keys are node objects, values are integers that indicate the distance (in hops) from the root node
GTree
  maxDepth : int
[read-only] The maximum depth of the tree, which is the maximum distance of any node from the root
GTree
  maxNumberPerLayer : uint
[read-only]
GTree
  parents : Dictionary
[read-only] The map (Dictionary) that contains the parents for each node (keys are node objects, with their parent node objects as values).
GTree
  restricted : Boolean
[read-only] Indicating flag if the returned tree is restricted to currently invisible nodes.
GTree
  root : INode
access to the current root node of the tree.
GTree
  XMLtree : XML
[read-only] Returns a nested XML representation of the tree.
GTree
Public Methods
 MethodDefined by
  
GTree(root:INode, graph:IGraph, restrict:Boolean = false)
Constructor to create a new GTree object, the tree will not immediately be initialised, but this will happen as soon as any attributes or methods are accessed, that require the tree to be initialised (late initialisation).
GTree
  
areSiblings(n:INode, m:INode):Boolean
Checks if two nodes are siblings or not.
GTree
  
Each node is also the i'th child of it's parent.
GTree
  
getChildren(n:INode):Array
An array that contains all children of this node in the tree in the order of each child's child index.
GTree
  
Get the distance of a particular node from the root.
GTree
  
This method returns the node, which is the i'th child of a given (parent) node.
GTree
  
getLimitedNodes(limit:int):Dictionary
This method returns a map (Object) containing only the nodes which are within a certain distance of the root node.
GTree
  
The number of children of any node in the tree.
GTree
  
Returns the number of siblings of a node, including the node itself so basically this is the number of the children of the node's parents.
GTree
  
This returns the number of nodes that have exactly the specified distance.
GTree
  
initTree():Dictionary
This initialiases the (spanning) tree using BFS (Breadth first search).
GTree
Property detail
distancesproperty
distances:Dictionary  [read-only]

The map that contains the distance for each node (keys are node objects, values are integers that indicate the distance (in hops) from the root node

Implementation
    public function get distances():Dictionary
maxDepthproperty 
maxDepth:int  [read-only]

The maximum depth of the tree, which is the maximum distance of any node from the root

Implementation
    public function get maxDepth():int
maxNumberPerLayerproperty 
maxNumberPerLayer:uint  [read-only]Implementation
    public function get maxNumberPerLayer():uint
parentsproperty 
parents:Dictionary  [read-only]

The map (Dictionary) that contains the parents for each node (keys are node objects, with their parent node objects as values).

Implementation
    public function get parents():Dictionary
restrictedproperty 
restricted:Boolean  [read-only]

Indicating flag if the returned tree is restricted to currently invisible nodes.

Implementation
    public function get restricted():Boolean
rootproperty 
root:INode  [read-write]

access to the current root node of the tree. If a new root node is set, this means the tree has to be recalculated.

Implementation
    public function get root():INode
    public function set root(value:INode):void
XMLtreeproperty 
XMLtree:XML  [read-only]

Returns a nested XML representation of the tree. It will only contain tags with all the attributes of the source GraphML data, nothing else. Beware, if the created tree is restriced to visible nodes, you will only get those.

Implementation
    public function get XMLtree():XML
Constructor detail
GTree()constructor
public function GTree(root:INode, graph:IGraph, restrict:Boolean = false)

Constructor to create a new GTree object, the tree will not immediately be initialised, but this will happen as soon as any attributes or methods are accessed, that require the tree to be initialised (late initialisation).

Parameters
root:INode — The root node of the tree.
 
graph:IGraph — The graph that this tree is a subset of.
 
restrict:Boolean (default = false) — A flag to indicate that the resulting tree should be restricted to currently invisible nodes.
Method detail
areSiblings()method
public function areSiblings(n:INode, m:INode):Boolean

Checks if two nodes are siblings or not.

Parameters
n:INode — First node to check.
 
m:INode — Potential sibling of n.

Returns
Boolean — True if the nodes are siblings, false otherwise.
getChildIndex()method 
public function getChildIndex(n:INode):int

Each node is also the i'th child of it's parent. This index is called the child index. The child index of each node is stored and can be looked up by this method.

Parameters
n:INode — The node lookup its child index.

Returns
int — The child index of this node.
getChildren()method 
public function getChildren(n:INode):Array

An array that contains all children of this node in the tree in the order of each child's child index.

Parameters
n:INode — The parent node.

Returns
Array — The array of children of the given node.
getDistance()method 
public function getDistance(n:INode):int

Get the distance of a particular node from the root.

Parameters
n:INode — The node object for which the distance is requested.

Returns
int — The distance from the root in hops.
getIthChildPerNode()method 
public function getIthChildPerNode(n:INode, i:int):INode

This method returns the node, which is the i'th child of a given (parent) node. Note that 'i' starts with 0, i.e. the frist child is actually the 0th child.

Parameters
n:INode — The parent node.
 
i:int — The child index of the desired child.

Returns
INode — The node which is it the i'th child of node n.
getLimitedNodes()method 
public function getLimitedNodes(limit:int):Dictionary

This method returns a map (Object) containing only the nodes which are within a certain distance of the root node.

Parameters
limit:int — The distance limit.

Returns
Dictionary — An object containing a map of node id's which are within the distance limit.
getNoChildren()method 
public function getNoChildren(n:INode):int

The number of children of any node in the tree.

Parameters
n:INode — parent node.

Returns
int — The number of its children.
getNoSiblings()method 
public function getNoSiblings(n:INode):int

Returns the number of siblings of a node, including the node itself so basically this is the number of the children of the node's parents. If the node has no parent, it is the root node and therefore the number of its sibling including itself is 1.

Parameters
n:INode — The node for which its number of siblings is required.

Returns
int — The number of of siblings plus the node itself.
getNumberNodesWithDistance()method 
public function getNumberNodesWithDistance(d:uint):uint

This returns the number of nodes that have exactly the specified distance.

Parameters
d:uint — The distance from the root.

Returns
uint — The number of nodes in the tree with distance d.
initTree()method 
public function initTree():Dictionary

This initialiases the (spanning) tree using BFS (Breadth first search).

Returns
Dictionary — The map that contains each node's parent node.