Packageflare.vis.data
Classpublic class TreeBuilder
SubclassesSpanningTree

Calculates a spanning tree for a graph structure. This class can create spanning trees by breadth-first search, depth-first search, or by computing a minimum spanning tree. The default is to find a minimum spanning tree, which in turn defaults to breadth-first search if no edge weight function is provided.

This class can annotate graph edges as belonging to the spanning tree (done if the annotateEdges property is true), and can construct a Tree instance (done if the buildTree property is true). Generated Tree instances are stored in the tree property. Generated trees contain the original nodes and edges in the input graph, and any previous parent or child links for input nodes will be cleared and overwritten.

This class is intended as a support class for creating spanning trees for flare.vis.data.Data instances. To create annotated spanning trees for other purposes, see the flare.analytics.graph.SpanningTree class, which provides a tree builder that can also be used a visualization operator.



Public Properties
 PropertyDefined by
  annotateEdges : Boolean
Flag indicating if edges in the spanning tree should be annotated.
TreeBuilder
  buildTree : Boolean
Flag indicating if a spanning tree instance should be created.
TreeBuilder
  edgeWeight : Function
A function determining edge weights used in the spanning tree calculation.
TreeBuilder
  links : int
The link type to consider when constructing a spanning tree.
TreeBuilder
  policy : String
The traveral policy used to generate the spanning tree.
TreeBuilder
  root : NodeSprite
The root node for the spanning tree.
TreeBuilder
  spanningField : String
The property with which to annotate edges that make up the spanning tree.
TreeBuilder
  tree : Tree
[read-only] The tree created by this operator.
TreeBuilder
Public Methods
 MethodDefined by
  
TreeBuilder(policy:String = null, buildTree:Boolean = true, annotateEdges:Boolean = false, root:NodeSprite = null, edgeWeight:* = null)
Creates a new SpanningTree operator
TreeBuilder
  
calculate(data:Data, n:NodeSprite):void
Calculates the spanning tree.
TreeBuilder
Public Constants
 ConstantDefined by
  BREADTH_FIRST : String = "breadth-first"
[static] Policy for a spanning tree built using breadth-first search.
TreeBuilder
  DEPTH_FIRST : String = "depth-first"
[static] Policy for a spanning tree built using depth-first search.
TreeBuilder
  MINIMUM_SPAN : String = "minimum-span"
[static] Policy for building a minimum spanning tree.
TreeBuilder
Property detail
annotateEdgesproperty
public var annotateEdges:Boolean

Flag indicating if edges in the spanning tree should be annotated. If so, the spanningField property will be set for each edge in the graph.

buildTreeproperty 
public var buildTree:Boolean

Flag indicating if a spanning tree instance should be created.

edgeWeightproperty 
edgeWeight:Function  [read-write]

A function determining edge weights used in the spanning tree calculation. When setting this value, one can pass in either a Function, which should take an EdgeSprite as input and return a Number as output, or a String, in which case the string will be used as a property name from which to retrieve the edge weight value from an EdgeSprite instance. If the value is null (the default) all edges will be assumed to have weight 1.

NOTE: Edge weights must be greater than or equal to zero!

Implementation
    public function get edgeWeight():Function
    public function set edgeWeight(value:Function):void
linksproperty 
links:int  [read-write]

The link type to consider when constructing a spanning tree. Should be one of NodeSprite.GRAPH_LINKS, NodeSprite.IN_LINKS, or NodeSprite.OUT_LINKS.

Implementation
    public function get links():int
    public function set links(value:int):void
policyproperty 
policy:String  [read-write]

The traveral policy used to generate the spanning tree. Should be one of DEPTH_FIRST, BREADTH_FIRST, or MINIMUM_SPAN (default).

Implementation
    public function get policy():String
    public function set policy(value:String):void
rootproperty 
public var root:NodeSprite

The root node for the spanning tree.

spanningFieldproperty 
spanningField:String  [read-write]

The property with which to annotate edges that make up the spanning tree. The default value is "props.spanning". This property is used to annotate edges as "true" (if in the spanning forest) or "false" (if not in the spanning forest).

Implementation
    public function get spanningField():String
    public function set spanningField(value:String):void
treeproperty 
tree:Tree  [read-only]

The tree created by this operator.

Implementation
    public function get tree():Tree
Constructor detail
TreeBuilder()constructor
public function TreeBuilder(policy:String = null, buildTree:Boolean = true, annotateEdges:Boolean = false, root:NodeSprite = null, edgeWeight:* = null)

Creates a new SpanningTree operator

Parameters
policy:String (default = null) — the spanning tree creation policy. The default is SpanningTree.MINIMUM_SPAN
 
buildTree:Boolean (default = true) — if true, this operator will build a new Tree instance containing the spanning tree
 
annotateEdges:Boolean (default = false) — if true, this operator will annotate the edges of the original graph as belonging to the spanning tree
 
root:NodeSprite (default = null) — the root node from which to compute the spanning tree
 
edgeWeight:* (default = null) — the edge weight values. This can either be a Function that returns weight values or a String providing the name of a property to look up on EdgeSprite instances.
Method detail
calculate()method
public function calculate(data:Data, n:NodeSprite):void

Calculates the spanning tree.

Parameters
data:Data — the data set containing a graph
 
n:NodeSprite — the root of the spanning tree
Constant detail
BREADTH_FIRSTconstant
public static const BREADTH_FIRST:String = "breadth-first"

Policy for a spanning tree built using breadth-first search.

DEPTH_FIRSTconstant 
public static const DEPTH_FIRST:String = "depth-first"

Policy for a spanning tree built using depth-first search.

MINIMUM_SPANconstant 
public static const MINIMUM_SPAN:String = "minimum-span"

Policy for building a minimum spanning tree.