RGraph.js

Author: Nicolas Garcia Belmonte

Copyright: Copyright 2008-2009 by Nicolas Garcia Belmonte.

Homepage: http://thejit.org

Version: 1.0.8a

License: BSD License

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the organization nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY Nicolas Garcia Belmonte ``AS IS’’ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL Nicolas Garcia Belmonte BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Summary
RGraph.jsAuthor: Nicolas Garcia Belmonte
ComplexA multi-purpose Complex Class with common methods.
Functions
ComplexComplex constructor.
cloneReturns a copy of the current object.
toPolarTransforms cartesian to polar coordinates.
normCalculates the complex norm.
squaredNormCalculates the complex squared norm.
addReturns the result of adding two complex numbers.
prodReturns the result of multiplying two complex numbers.
conjugateReturns the conjugate por this complex.
scaleReturns the result of scaling a Complex instance.
equalsComparison method.
$addReturns the result of adding two complex numbers.
$prodReturns the result of multiplying two complex numbers.
$conjugateReturns the conjugate for this complex.
$scaleReturns the result of scaling a Complex instance.
$divReturns the division of two complex numbers.
PolarA multi purpose polar representation.
Functions
PolarPolar constructor.
cloneReturns a copy of the current object.
toComplexTranslates from polar to cartesian coordinates and returns a new Complex instance.
addAdds two Polar instances.
scaleScales a polar norm.
equalsComparison method.
$addAdds two Polar instances affecting the current object.
$maddAdds two Polar instances affecting the current object.
$scaleScales a polar instance affecting the object.
interpolateCalculates a polar interpolation between two points at a given delta moment.
ConfigRGraph global configuration object.
Properties
labelContainerId for label container.
levelDistanceThe actual distance between levels
nodeRadiusThe radius of the nodes displayed
allowVariableNodeDiametersSet this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).
nodeRangeDiametersDiameters range.
nodeRangeValuesThe interval of the values of the first object of your dataSet.
fpsanimation frames per second
animationTime
interpolation
GraphUtilA multi purpose object to do graph traversal and processing.
Functions
filterFor internal use only.
getNodeReturns a graph’s node with a specified id.
eachNodeIterates over graph nodes performing an action.
eachAdjacencyIterates over a node adjacencies applying the action function.
computeLevelsPerforms a BFS traversal setting correct level for nodes.
eachBFSPerforms a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnodeAfter a BFS traversal the depth property of each node has been modified.
getSubnodesCollects all subnodes for a specified node.
getParentsReturns all nodes having a depth that is less than the node’s depth property.
cleanCleans flags from nodes (by setting the flag property to false).
GraphOpAn object holding unary and binary graph operations such as removingNodes, removingEdges, adding two graphs and morphing.
Functions
removeNodeRemoves one or more nodes from the visualization.
removeEdgeRemoves one or more edges from the visualization.
sumAdds a new graph to the visualization.
morphThis method will morph the current visualized graph into the new json representation passed in the method.
GraphPlotAn object that performs specific radial layouts for a generic graph structure.
Properties
labelsHiddenA flag value indicating if node labels are being displayed or not.
labelContainerLabel DOM element
labelsLabel DOM elements hash.
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels.
clearLabelsClears the label container.
disposeLabelRemoves a label.
animateAnimates the graph.
sequenceIteratively performs an action while refreshing the state of the visualization.
plotPlots a Graph.
plotNodePlots a graph node.
plotLinePlots a line connecting node and child nodes.
hideLabelHides a label having node.id as id.
plotLabelPlots a label for a given node.
fitsInCanvasReturns true or false if the label for the node is contained on the canvas dom element or not.
RGraphAn animated Graph with radial layout.
Functions
RGraphCreates a new RGraph instance.
loadTreeLoads a Graph from a json tree object http://blog.thejit.org
loadGraphLoads a Graph from a json graph object http://blog.thejit.org
refreshComputes positions and then plots.
flagRootFlags a node specified by id as root.
unflagRootUnflags all nodes.
getRootReturns the node flagged as root.
loadTreeFromJSONLoads a RGraph from a json object http://blog.thejit.org
loadGraphFromJSONLoads a RGraph from a json object http://blog.thejit.org
plotPlots the RGraph
computeComputes the graph nodes positions and stores this positions on property.
computePositionsPerforms the main algorithm for computing node positions.
setAngularWidthForNodesSets nodes angular widths.
setSubtreesAngularWidthsSets subtrees angular widths.
setSubtreeAngularWidthSets the angular width for a subtree.
computeAngularWidthsComputes nodes and subtrees angular widths.
getNodeAndParentAngleReturns the parent of the given node, also calculating its angle span.
tagChildrenEnumerates the children in order to mantain child ordering (second constraint of the paper).
onClickPerforms all calculations and animation when clicking on a label specified by id.
GraphA generic Graph class.
Functions and Properties
GraphCreates a new Graph instance.
nodesgraph nodes
getNodeReturns a Graph.Node from a specified id.
getAdjacenceReturns an array of Graph.Adjacence that connects nodes with id id and id2.
addNodeAdds a node.
addAdjacenceConnects nodes specified by obj and obj2.
removeNodeRemoves a Graph.Node from Graph that matches the specified id.
removeAdjacenceRemoves a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNodeReturns a Boolean instance indicating if node belongs to graph or not.
Graph.NodeBehaviour of the Graph node.
Functions
Graph.NodeNode constructor.
Properties
idA node’s id
nameA node’s name
dataThe dataSet object http://blog.thejit.org/?p=7
drawnNode flag
angle spanallowed angle span for adjacencies placement
posnode position
startPosnode from position
endPosnode to position
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
adjacenciesnode adjacencies
Functions
adjacentToIndicates if the node is adjacent to the node indicated by the specified id
getAdjacencyReturns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacencyConnects the node to the specified by id.
removeAdjacencyDeletes the Graph.Adjacence by id.
Graph.AdjacenceCreates a new Graph adjacence.
Properties
nodeFromOne of the two Graph.Nodes connected by this edge.
nodeToOne of the two Graph.Nodes connected by this edge.
dataA dataset object
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
TransAn object containing multiple type of transformations.
AnimationAn object that performs animations.

Complex

A multi-purpose Complex Class with common methods.

Summary
Functions
ComplexComplex constructor.
cloneReturns a copy of the current object.
toPolarTransforms cartesian to polar coordinates.
normCalculates the complex norm.
squaredNormCalculates the complex squared norm.
addReturns the result of adding two complex numbers.
prodReturns the result of multiplying two complex numbers.
conjugateReturns the conjugate por this complex.
scaleReturns the result of scaling a Complex instance.
equalsComparison method.
$addReturns the result of adding two complex numbers.
$prodReturns the result of multiplying two complex numbers.
$conjugateReturns the conjugate for this complex.
$scaleReturns the result of scaling a Complex instance.
$divReturns the division of two complex numbers.

Functions

Complex

var Complex= function()

Complex constructor.

Parameters

reA real number.
imAn real number representing the imaginary part.

Returns

A new Complex instance.

clone

clone: function()

Returns a copy of the current object.

Returns

A copy of the real object.

toPolar

toPolar: function()

Transforms cartesian to polar coordinates.

Returns

A new Polar instance.

norm

norm: function ()

Calculates the complex norm.

Returns

A real number representing the complex norm.

squaredNorm

squaredNorm: function ()

Calculates the complex squared norm.

Returns

A real number representing the complex squared norm.

add

add: function(pos)

Returns the result of adding two complex numbers.  Does not alter the original object.

Parameters

posA Complex initialized instance.

Returns

The result of adding two complex numbers.

prod

prod: function(pos)

Returns the result of multiplying two complex numbers.  Does not alter the original object.

Parameters

posA Complex initialized instance.

Returns

The result of multiplying two complex numbers.

conjugate

conjugate: function()

Returns the conjugate por this complex.

Returns

The conjugate por this complex.

scale

scale: function(factor)

Returns the result of scaling a Complex instance.  Does not alter the original object.

Parameters

factorA scale factor.

Returns

The result of scaling this complex to a factor.

equals

equals: function(c)

Comparison method.

$add

$add: function(pos)

Returns the result of adding two complex numbers.  Alters the original object.

Parameters

posA Complex initialized instance.

Returns

The result of adding two complex numbers.

$prod

$prod:function(pos)

Returns the result of multiplying two complex numbers.  Alters the original object.

Parameters

posA Complex initialized instance.

Returns

The result of multiplying two complex numbers.

$conjugate

$conjugate: function()

Returns the conjugate for this complex.  Alters the original object.

Returns

The conjugate for this complex.

$scale

$scale: function(factor)

Returns the result of scaling a Complex instance.  Alters the original object.

Parameters

factorA scale factor.

Returns

The result of scaling this complex to a factor.

$div

$div: function(pos)

Returns the division of two complex numbers.  Alters the original object.

Parameters

posA Complex number.

Returns

The result of scaling this complex to a factor.

Polar

A multi purpose polar representation.

Summary
Functions
PolarPolar constructor.
cloneReturns a copy of the current object.
toComplexTranslates from polar to cartesian coordinates and returns a new Complex instance.
addAdds two Polar instances.
scaleScales a polar norm.
equalsComparison method.
$addAdds two Polar instances affecting the current object.
$maddAdds two Polar instances affecting the current object.
$scaleScales a polar instance affecting the object.
interpolateCalculates a polar interpolation between two points at a given delta moment.

Functions

Polar

var Polar = function(theta,
rho)

Polar constructor.

Parameters

thetaAn angle.
rhoThe norm.

Returns

A new Polar instance.

clone

clone: function()

Returns a copy of the current object.

Returns

A copy of the real object.

toComplex

toComplex: function()

Translates from polar to cartesian coordinates and returns a new Complex instance.

Returns

A new Complex instance.

add

add: function(polar)

Adds two Polar instances.

Returns

A new Polar instance.

scale

scale: function(number)

Scales a polar norm.

Returns

A new Polar instance.

equals

equals: function(c)

Comparison method.

$add

$add: function(polar)

Adds two Polar instances affecting the current object.

Returns

The changed object.

$madd

$madd: function(polar)

Adds two Polar instances affecting the current object.  The resulting theta angle is modulo 2pi.

Returns

The changed object.

$scale

$scale: function(number)

Scales a polar instance affecting the object.

Returns

The changed object.

interpolate

interpolate: function(elem,
delta)

Calculates a polar interpolation between two points at a given delta moment.

Returns

A new Polar instance representing an interpolation between this and elem

Config

RGraph global configuration object.  Contains important properties to enable customization and proper behavior for the RGraph.

Summary
Properties
labelContainerId for label container.
levelDistanceThe actual distance between levels
nodeRadiusThe radius of the nodes displayed
allowVariableNodeDiametersSet this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).
nodeRangeDiametersDiameters range.
nodeRangeValuesThe interval of the values of the first object of your dataSet.
fpsanimation frames per second
animationTime
interpolation

Properties

labelContainer

Id for label container.  The label container is a div dom element that must be explicitly added to your page in order to enable the RGraph.

levelDistance

The actual distance between levels

nodeRadius

The radius of the nodes displayed

allowVariableNodeDiameters

Set this to true if you want your node diameters to be proportional to you first dataset object value property (i.e data[0].value).  This will allow you to represent weighted tree/graph nodes.

nodeRangeDiameters

Diameters range.  For variable node weights.

nodeRangeValues

The interval of the values of the first object of your dataSet.  A superset of the values can also be specified.

fps

animation frames per second

animationTime

interpolation

GraphUtil

A multi purpose object to do graph traversal and processing.

Summary
Functions
filterFor internal use only.
getNodeReturns a graph’s node with a specified id.
eachNodeIterates over graph nodes performing an action.
eachAdjacencyIterates over a node adjacencies applying the action function.
computeLevelsPerforms a BFS traversal setting correct level for nodes.
eachBFSPerforms a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnodeAfter a BFS traversal the depth property of each node has been modified.
getSubnodesCollects all subnodes for a specified node.
getParentsReturns all nodes having a depth that is less than the node’s depth property.
cleanCleans flags from nodes (by setting the flag property to false).

Functions

filter

filter: function(param)

For internal use only.  Provides a filtering function based on flags.

getNode

getNode: function(graph,
id)

Returns a graph’s node with a specified id.

eachNode

eachNode: function(graph,
action,
flags)

Iterates over graph nodes performing an action.

eachAdjacency

eachAdjacency: function(node,
action,
flags)

Iterates over a node adjacencies applying the action function.

computeLevels

computeLevels: function(graph,
id,
flags)

Performs a BFS traversal setting correct level for nodes.

eachBFS

eachBFS: function(graph,
id,
action,
flags)

Performs a BFS traversal of a graph beginning by the node of id id and performing action on each node.  This traversal ignores nodes or edges having the property ignore setted to true.

eachSubnode

eachSubnode: function(node,
action,
flags)

After a BFS traversal the depth property of each node has been modified.  Now the graph can be traversed as a tree.  This method iterates for each subnode that has depth larger than the specified node.

getSubnodes

getSubnodes: function(graph,
id,
level,
flags)

Collects all subnodes for a specified node.  The level parameter filters nodes having relative depth of level from the root node.

getParents

getParents: function(graph,
node)

Returns all nodes having a depth that is less than the node’s depth property.

clean

clean: function(graph)

Cleans flags from nodes (by setting the flag property to false).

GraphOp

An object holding unary and binary graph operations such as removingNodes, removingEdges, adding two graphs and morphing.

Summary
Functions
removeNodeRemoves one or more nodes from the visualization.
removeEdgeRemoves one or more edges from the visualization.
sumAdds a new graph to the visualization.
morphThis method will morph the current visualized graph into the new json representation passed in the method.

Functions

removeNode

removeNode: function(viz,
node,
opt)

Removes one or more nodes from the visualization.  It can also perform several animations like fading sequentially, fading concurrently, iterating or replotting.

Parameters

vizThe visualization object (an RGraph instance in this case).
nodeThe node’s id.  Can also be an array having many ids.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, fade:con or iter.  The other property is the duration in milliseconds.

removeEdge

removeEdge: function(viz,
vertex,
opt)

Removes one or more edges from the visualization.  It can also perform several animations like fading sequentially, fading concurrently, iterating or replotting.

Parameters

vizThe visualization object (an RGraph instance in this case).
vertexAn array having two strings which are the ids of the nodes connected by this edge: [‘id1’, ‘id2’].  Can also be a two dimensional array holding many edges: [[‘id1’, ‘id2’], [‘id3’, ‘id4’], ...].
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, fade:con or iter.  The other property is the duration in milliseconds.

sum

sum: function(viz,
json,
opt)

Adds a new graph to the visualization.  The json graph (or tree) must at least have a common node with the current graph plotted by the visualization.  The resulting graph can be defined as follows: http://mathworld.wolfram.com/GraphSum.html

Parameters

vizThe visualization object (an RGraph instance in this case).
jsonA json tree http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/, a json graph http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/ or an extended json graph http://blog.thejit.org/2008/08/05/weighted-nodes-weighted-edges/.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, fade:seq, or fade:con.  The other property is the duration in milliseconds.

morph

morph: function(viz,
json,
opt)

This method will morph the current visualized graph into the new json representation passed in the method.  Can also perform multiple animations.  The json object must at least have the root node in common with the current visualized graph.

Parameters

vizThe visualization object (an RGraph instance in this case).
jsonA json tree http://blog.thejit.org/2008/04/27/feeding-json-tree-structures-to-the-jit/, a json graph http://blog.thejit.org/2008/07/02/feeding-json-graph-structures-to-the-jit/ or an extended json graph http://blog.thejit.org/2008/08/05/weighted-nodes-weighted-edges/.
optAnimation options.  It’s an object with two properties: type, which can be nothing, replot, or fade.  The other property is the duration in milliseconds.

GraphPlot

An object that performs specific radial layouts for a generic graph structure.

Summary
Properties
labelsHiddenA flag value indicating if node labels are being displayed or not.
labelContainerLabel DOM element
labelsLabel DOM elements hash.
Functions
getLabelContainerLazy fetcher for the label container.
getLabelLazy fetcher for the label DOM element.
hideLabelsHides all labels.
clearLabelsClears the label container.
disposeLabelRemoves a label.
animateAnimates the graph.
sequenceIteratively performs an action while refreshing the state of the visualization.
plotPlots a Graph.
plotNodePlots a graph node.
plotLinePlots a line connecting node and child nodes.
hideLabelHides a label having node.id as id.
plotLabelPlots a label for a given node.
fitsInCanvasReturns true or false if the label for the node is contained on the canvas dom element or not.

Properties

labelsHidden

A flag value indicating if node labels are being displayed or not.

labelContainer

Label DOM element

labels

Label DOM elements hash.

Functions

getLabelContainer

getLabelContainer: function()

Lazy fetcher for the label container.

getLabel

getLabel: function(id)

Lazy fetcher for the label DOM element.

hideLabels

hideLabels: function (hide)

Hides all labels.

clearLabels

clearLabels: function(viz)

Clears the label container.

disposeLabel

disposeLabel: function(id)

Removes a label.

animate

animate: function(viz,
opt)

Animates the graph.

sequence

sequence: function(viz,
options)

Iteratively performs an action while refreshing the state of the visualization.

plot

plot: function(viz,
opt)

Plots a Graph.

plotNode

plotNode: function(node,
canvas)

Plots a graph node.

plotLine

plotLine: function(adj,
canvas)

Plots a line connecting node and child nodes.

hideLabel

hideLabel: function(node)

Hides a label having node.id as id.

plotLabel

plotLabel: function(canvas,
node,
controller)

Plots a label for a given node.

fitsInCanvas

fitsInCanvas: function(pos,
canvas)

Returns true or false if the label for the node is contained on the canvas dom element or not.

RGraph

An animated Graph with radial layout.

Go to http://blog.thejit.org to know what kind of JSON structure feeds this object.

Go to http://blog.thejit.org/?p=8 to know what kind of controller this class accepts.

Refer to the Config object to know what properties can be modified in order to customize this object.

The simplest way to create and layout a RGraph is

var canvas= new Canvas('infovis', {});
var rgraph= new RGraph(canvas, controller);
rgraph.loadTreeFromJSON(json);
rgraph.compute();
rgraph.plot();

A user should only interact with the Canvas, RGraph and Config objects/classes.  By implementing RGraph controllers you can also customize the RGraph behavior.

Summary
Functions
RGraphCreates a new RGraph instance.
loadTreeLoads a Graph from a json tree object http://blog.thejit.org
loadGraphLoads a Graph from a json graph object http://blog.thejit.org
refreshComputes positions and then plots.
flagRootFlags a node specified by id as root.
unflagRootUnflags all nodes.
getRootReturns the node flagged as root.
loadTreeFromJSONLoads a RGraph from a json object http://blog.thejit.org
loadGraphFromJSONLoads a RGraph from a json object http://blog.thejit.org
plotPlots the RGraph
computeComputes the graph nodes positions and stores this positions on property.
computePositionsPerforms the main algorithm for computing node positions.
setAngularWidthForNodesSets nodes angular widths.
setSubtreesAngularWidthsSets subtrees angular widths.
setSubtreeAngularWidthSets the angular width for a subtree.
computeAngularWidthsComputes nodes and subtrees angular widths.
getNodeAndParentAngleReturns the parent of the given node, also calculating its angle span.
tagChildrenEnumerates the children in order to mantain child ordering (second constraint of the paper).
onClickPerforms all calculations and animation when clicking on a label specified by id.

Functions

RGraph

var RGraph = function(canvas,
controller)

Creates a new RGraph instance.

Parameters

canvasA Canvas instance.
controlleroptional a RGraph controller http://blog.thejit.org/?p=8

loadTree

loadTree: function(json)

Loads a Graph from a json tree object http://blog.thejit.org

loadGraph

loadGraph: function(json)

Loads a Graph from a json graph object http://blog.thejit.org

refresh

refresh: function()

Computes positions and then plots.

flagRoot

flagRoot: function(id)

Flags a node specified by id as root.

unflagRoot

unflagRoot: function()

Unflags all nodes.

getRoot

getRoot: function()

Returns the node flagged as root.

loadTreeFromJSON

loadTreeFromJSON: function(json)

Loads a RGraph from a json object http://blog.thejit.org

loadGraphFromJSON

loadGraphFromJSON: function(json,
i)

Loads a RGraph from a json object http://blog.thejit.org

plot

plot: function()

Plots the RGraph

compute

compute: function(property)

Computes the graph nodes positions and stores this positions on property.

computePositions

computePositions: function(property)

Performs the main algorithm for computing node positions.

setAngularWidthForNodes

setAngularWidthForNodes: function()

Sets nodes angular widths.

setSubtreesAngularWidths

Sets subtrees angular widths.

setSubtreeAngularWidth

setSubtreeAngularWidth: function(elem)

Sets the angular width for a subtree.

computeAngularWidths

computeAngularWidths: function ()

Computes nodes and subtrees angular widths.

getNodeAndParentAngle

getNodeAndParentAngle: function(id)

Returns the parent of the given node, also calculating its angle span.

tagChildren

tagChildren: function(par,
id)

Enumerates the children in order to mantain child ordering (second constraint of the paper).

onClick

onClick: function(id)

Performs all calculations and animation when clicking on a label specified by id.  The label id is the same id as its homologue node.

Graph

A generic Graph class.

Summary
Functions and Properties
GraphCreates a new Graph instance.
nodesgraph nodes
getNodeReturns a Graph.Node from a specified id.
getAdjacenceReturns an array of Graph.Adjacence that connects nodes with id id and id2.
addNodeAdds a node.
addAdjacenceConnects nodes specified by obj and obj2.
removeNodeRemoves a Graph.Node from Graph that matches the specified id.
removeAdjacenceRemoves a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNodeReturns a Boolean instance indicating if node belongs to graph or not.

Functions and Properties

Graph

var Graph= function()

Creates a new Graph instance.

nodes

graph nodes

getNode

getNode: function(id)

Returns a Graph.Node from a specified id.

getAdjacence

getAdjacence: function (id,
id2)

Returns an array of Graph.Adjacence that connects nodes with id id and id2.

addNode

addNode: function(obj)

Adds a node.

Parameters

objA Graph.Node object.

addAdjacence

addAdjacence: function (obj,
obj2,
weight)

Connects nodes specified by obj and obj2.  If not found, nodes are created.

Parameters

obja Graph.Node object.
obj2Another Graph.Node object.
dataA DataSet object.

removeNode

removeNode: function(id)

Removes a Graph.Node from Graph that matches the specified id.

removeAdjacence

removeAdjacence: function(id1,
id2)

Removes a Graph.Adjacence from Graph that matches the specified id1 and id2.

hasNode

hasNode: function(id)

Returns a Boolean instance indicating if node belongs to graph or not.

Parameters

idNode id.

Returns

A Boolean instance indicating if node belongs to graph or not.

Graph.Node

Behaviour of the Graph node.

Summary
Functions
Graph.NodeNode constructor.
Properties
idA node’s id
nameA node’s name
dataThe dataSet object http://blog.thejit.org/?p=7
drawnNode flag
angle spanallowed angle span for adjacencies placement
posnode position
startPosnode from position
endPosnode to position
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha
adjacenciesnode adjacencies
Functions
adjacentToIndicates if the node is adjacent to the node indicated by the specified id
getAdjacencyReturns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacencyConnects the node to the specified by id.
removeAdjacencyDeletes the Graph.Adjacence by id.

Functions

Graph.Node

Graph.Node = function(id,
name,
data)

Node constructor.

Parameters

idThe node unique identifier id.
nameA node’s name.
dataPlace to store some extra information (can be left to null).

Returns

A new Graph.Node instance.

Properties

id

A node’s id

name

A node’s name

data

The dataSet object http://blog.thejit.org/?p=7

drawn

Node flag

angle span

allowed angle span for adjacencies placement

pos

node position

startPos

node from position

endPos

node to position

alpha

node alpha

startAlpha

node start alpha

endAlpha

node end alpha

adjacencies

node adjacencies

Functions

adjacentTo

adjacentTo: function(node)

Indicates if the node is adjacent to the node indicated by the specified id

Parameters

idA node id.

Returns

A Boolean instance indicating whether this node is adjacent to the specified by id or not.

getAdjacency

getAdjacency: function(id)

Returns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.

Parameters

idA node id.

addAdjacency

addAdjacency: function(node,
data)

Connects the node to the specified by id.

Parameters

idA node id.

removeAdjacency

removeAdjacency: function(id)

Deletes the Graph.Adjacence by id.

Parameters

idA node id.

Graph.Adjacence

Creates a new Graph adjacence.

Summary
Properties
nodeFromOne of the two Graph.Nodes connected by this edge.
nodeToOne of the two Graph.Nodes connected by this edge.
dataA dataset object
alphanode alpha
startAlphanode start alpha
endAlphanode end alpha

Properties

nodeFrom

One of the two Graph.Nodes connected by this edge.

nodeTo

One of the two Graph.Nodes connected by this edge.

data

A dataset object

alpha

node alpha

startAlpha

node start alpha

endAlpha

node end alpha

Trans

An object containing multiple type of transformations.  Based on the mootools library http://mootools.net.

Animation

An object that performs animations.  Based on Fx.Base from Mootools.

var Complex= function()
Complex constructor.
clone: function()
Returns a copy of the current object.
toPolar: function()
Transforms cartesian to polar coordinates.
norm: function ()
Calculates the complex norm.
squaredNorm: function ()
Calculates the complex squared norm.
add: function(pos)
Returns the result of adding two complex numbers.
prod: function(pos)
Returns the result of multiplying two complex numbers.
conjugate: function()
Returns the conjugate por this complex.
scale: function(factor)
Returns the result of scaling a Complex instance.
equals: function(c)
Comparison method.
$add: function(pos)
Returns the result of adding two complex numbers.
$prod:function(pos)
Returns the result of multiplying two complex numbers.
$conjugate: function()
Returns the conjugate for this complex.
$scale: function(factor)
Returns the result of scaling a Complex instance.
$div: function(pos)
Returns the division of two complex numbers.
var Polar = function(theta,
rho)
Polar constructor.
clone: function()
Returns a copy of the current object.
toComplex: function()
Translates from polar to cartesian coordinates and returns a new Complex instance.
A multi-purpose Complex Class with common methods.
add: function(polar)
Adds two Polar instances.
scale: function(number)
Scales a polar norm.
equals: function(c)
Comparison method.
$add: function(polar)
Adds two Polar instances affecting the current object.
$madd: function(polar)
Adds two Polar instances affecting the current object.
$scale: function(number)
Scales a polar instance affecting the object.
interpolate: function(elem,
delta)
Calculates a polar interpolation between two points at a given delta moment.
An animated Graph with radial layout.
filter: function(param)
For internal use only.
getNode: function(graph,
id)
Returns a graph’s node with a specified id.
eachNode: function(graph,
action,
flags)
Iterates over graph nodes performing an action.
eachAdjacency: function(node,
action,
flags)
Iterates over a node adjacencies applying the action function.
computeLevels: function(graph,
id,
flags)
Performs a BFS traversal setting correct level for nodes.
eachBFS: function(graph,
id,
action,
flags)
Performs a BFS traversal of a graph beginning by the node of id id and performing action on each node.
eachSubnode: function(node,
action,
flags)
After a BFS traversal the depth property of each node has been modified.
getSubnodes: function(graph,
id,
level,
flags)
Collects all subnodes for a specified node.
getParents: function(graph,
node)
Returns all nodes having a depth that is less than the node’s depth property.
clean: function(graph)
Cleans flags from nodes (by setting the flag property to false).
removeNode: function(viz,
node,
opt)
Removes one or more nodes from the visualization.
removeEdge: function(viz,
vertex,
opt)
Removes one or more edges from the visualization.
sum: function(viz,
json,
opt)
Adds a new graph to the visualization.
morph: function(viz,
json,
opt)
This method will morph the current visualized graph into the new json representation passed in the method.
getLabelContainer: function()
Lazy fetcher for the label container.
getLabel: function(id)
Lazy fetcher for the label DOM element.
hideLabels: function (hide)
Hides all labels.
clearLabels: function(viz)
Clears the label container.
disposeLabel: function(id)
Removes a label.
animate: function(viz,
opt)
Animates the graph.
sequence: function(viz,
options)
Iteratively performs an action while refreshing the state of the visualization.
plot: function(viz,
opt)
Plots a Graph.
plotNode: function(node,
canvas)
Plots a graph node.
plotLine: function(adj,
canvas)
Plots a line connecting node and child nodes.
hideLabel: function(node)
Hides a label having node.id as id.
plotLabel: function(canvas,
node,
controller)
Plots a label for a given node.
fitsInCanvas: function(pos,
canvas)
Returns true or false if the label for the node is contained on the canvas dom element or not.
var RGraph = function(canvas,
controller)
Creates a new RGraph instance.
loadTree: function(json)
Loads a Graph from a json tree object http://blog.thejit.org
loadGraph: function(json)
Loads a Graph from a json graph object http://blog.thejit.org
refresh: function()
Computes positions and then plots.
flagRoot: function(id)
Flags a node specified by id as root.
unflagRoot: function()
Unflags all nodes.
getRoot: function()
Returns the node flagged as root.
loadTreeFromJSON: function(json)
Loads a RGraph from a json object http://blog.thejit.org
loadGraphFromJSON: function(json,
i)
Loads a RGraph from a json object http://blog.thejit.org
plot: function()
Plots the RGraph
compute: function(property)
Computes the graph nodes positions and stores this positions on property.
computePositions: function(property)
Performs the main algorithm for computing node positions.
setAngularWidthForNodes: function()
Sets nodes angular widths.
setSubtreeAngularWidth: function(elem)
Sets the angular width for a subtree.
computeAngularWidths: function ()
Computes nodes and subtrees angular widths.
getNodeAndParentAngle: function(id)
Returns the parent of the given node, also calculating its angle span.
tagChildren: function(par,
id)
Enumerates the children in order to mantain child ordering (second constraint of the paper).
onClick: function(id)
Performs all calculations and animation when clicking on a label specified by id.
var Graph= function()
Creates a new Graph instance.
getNode: function(id)
Returns a Graph.Node from a specified id.
Behaviour of the Graph node.
getAdjacence: function (id,
id2)
Returns an array of Graph.Adjacence that connects nodes with id id and id2.
Creates a new Graph adjacence.
addNode: function(obj)
Adds a node.
addAdjacence: function (obj,
obj2,
weight)
Connects nodes specified by obj and obj2.
removeNode: function(id)
Removes a Graph.Node from Graph that matches the specified id.
removeAdjacence: function(id1,
id2)
Removes a Graph.Adjacence from Graph that matches the specified id1 and id2.
hasNode: function(id)
Returns a Boolean instance indicating if node belongs to graph or not.
A generic Graph class.
Graph.Node = function(id,
name,
data)
Node constructor.
adjacentTo: function(node)
Indicates if the node is adjacent to the node indicated by the specified id
getAdjacency: function(id)
Returns a Graph.Adjacence that connects the current Graph.Node with the node having id as id.
addAdjacency: function(node,
data)
Connects the node to the specified by id.
removeAdjacency: function(id)
Deletes the Graph.Adjacence by id.
A multi purpose polar representation.
RGraph global configuration object.
A multi-purpose Canvas object decorator.
Close