thinkmap.graph.Tree

extends:
Jump To: Members Events

A Tree is a special type of graph that maintains a tree structure.

A tree is best thought of as a hierarchical structure where all nodes in the tree are the descendant of a single root node "the root". Every node in a tree can have only 1 parent, with the exception being the root which has no parents.

Every node in a tree can have 0 or more children. A node without any children is considered a leaf.

One of the important characteristics of a tree is that each node has a depth. The depth refers to how many ancestors a node is removed from the root. If a node has the root for a parent, then its depth will be 1 and its children will have a depth of 2. The root has a depth of 0.

Examples:

Construct a new tree with a root node var tree = new thinkmap.graph.Tree(node);
Construct a tree without a root node and then build the tree var tree = new thinkmap.graph.Tree(); tree.root(tree.createNode({label:'root'}) .addEdge(tree.root(),tree.createNode({label: 'Node A'}) .addEdge(tree.root(),tree.createNode({label: 'Node B'});

Constructor

Instance Methods

Defined in thinkmap.graph.Tree:

Events

addnode : function ( thinkmap.graph.Node )

This event is fired each time a node is added to the graph. The parameter is the node added.

addedge : function ( thinkmap.graph.Edge )

This event is fired each time an edge is added to the graph. The parameter is the edge added.

removenode : function ( thinkmap.graph.Node )

This event is fired each time a node is removed from the graph. The parameter is the node removed.

removeedge : function ( thinkmap.graph.Edge )

This event is fired each time an edge is removed from the graph. The parameter is the edge removed.

dataupdate : function ( thinkmap.graph.Entity )

This event is fired each time each time dataUpdate on graph is called. This typically signifies that some change occured to the entity's data object. The single parameter is the entity passed to the graphs dataUpdate method.