| Package | org.juicekit.util.data |
| Class | public class GraphUtil |
| Method | Defined by | ||
|---|---|---|---|
|
balancedTree(breadth:uint, depth:uint):Tree
[static]
Returns a balanced tree of the requested breadth and depth.
| GraphUtil | ||
|
clique(n:uint):Data
[static]
Returns a clique of given size.
| GraphUtil | ||
|
diamondTree(b:int, d1:int, d2:int):Tree
[static]
Create a diamond tree, with a given branching factor at
each level, and depth levels for the two main branches.
| GraphUtil | ||
|
grid(m:uint, n:uint):Data
[static]
Returns a graph structured as an m-by-n grid.
| GraphUtil | ||
|
honeycomb(levels:uint):Data
[static]
| GraphUtil | ||
|
leftDeepTree(depth:uint):Tree
[static]
Returns a left deep binary tree
| GraphUtil | ||
|
nodes(n:uint):Data
[static]
Builds a completely unconnected (edge-free) graph with the given
number of nodes
| GraphUtil | ||
|
printTree(n:NodeSprite, d:int):void
[static]
| GraphUtil | ||
|
rightDeepTree(depth:uint):Tree
[static]
Returns a right deep binary tree
| GraphUtil | ||
|
star(n:uint):Data
[static]
Builds a "star" graph with one central hub connected to the given
number of satellite nodes.
| GraphUtil | ||
|
treeMap(dataArray:Array, levels:Array, metrics:Array, rowFilter:Function = null):Tree
[static]
Generates a treemap data structure given an array of data objects. The tree will be generated with the levels specified. Consider a case if dataArray is:
Metrics will sum by default.
You can perform different calculations on the metrics using flare query expressions. | GraphUtil | ||
|
wordTree(arr:Array, rootword:String = "hotels", reverse:Boolean = true, addTerminator:Boolean = false, removeStartEnd:Boolean = true, coalesceNodes:Boolean = true, delimiter:String = " "):Tree
[static]
Generates a word tree structure from an array of objects.
| GraphUtil | ||
| balancedTree | () | method |
public static function balancedTree(breadth:uint, depth:uint):TreeReturns a balanced tree of the requested breadth and depth.
Parametersbreadth:uint — the breadth of each level of the tree
|
|
depth:uint — the depth of the tree
|
Tree — a balanced tree
|
| clique | () | method |
public static function clique(n:uint):DataReturns a clique of given size. A clique is a graph in which every node is a neighbor of every other node.
Parametersn:uint — the number of nodes in the graph
|
Data — a clique of size n
|
| diamondTree | () | method |
public static function diamondTree(b:int, d1:int, d2:int):TreeCreate a diamond tree, with a given branching factor at each level, and depth levels for the two main branches.
Parametersb:int — the number of children of each branch node
|
|
d1:int — the length of the first (left) branch
|
|
d2:int — the length of the second (right) branch
|
Tree — the generated Tree
|
| grid | () | method |
public static function grid(m:uint, n:uint):DataReturns a graph structured as an m-by-n grid.
Parametersm:uint — the number of rows of the grid
|
|
n:uint — the number of columns of the grid
|
Data — an m-by-n grid structured graph
|
| honeycomb | () | method |
public static function honeycomb(levels:uint):DataParameters
levels:uint |
Data |
| leftDeepTree | () | method |
public static function leftDeepTree(depth:uint):TreeReturns a left deep binary tree
Parametersdepth:uint — the depth of the tree
|
Tree — the generated tree
|
| nodes | () | method |
public static function nodes(n:uint):DataBuilds a completely unconnected (edge-free) graph with the given number of nodes
Parametersn:uint — the number of nodes
|
Data — a graph with n nodes and no edges
|
| printTree | () | method |
public static function printTree(n:NodeSprite, d:int):voidParameters
n:NodeSprite |
|
d:int |
| rightDeepTree | () | method |
public static function rightDeepTree(depth:uint):TreeReturns a right deep binary tree
Parametersdepth:uint — the depth of the tree
|
Tree — the generated Tree
|
| star | () | method |
public static function star(n:uint):DataBuilds a "star" graph with one central hub connected to the given number of satellite nodes.
Parametersn:uint — the number of points of the star
|
Data — a "star" graph with n points, for a total of n+1 nodes
|
| treeMap | () | method |
public static function treeMap(dataArray:Array, levels:Array, metrics:Array, rowFilter:Function = null):Tree
Generates a treemap data structure given an array of data objects.
The tree will be generated with the levels specified.
Consider a case if dataArray is:
[{state: 'California': year: '2009', people: 200, avg_income: 600},
{state: 'California': year: '2008', people: 200, avg_income: 400},
{state: 'Oregon': year: '2009', people: 400, avg_income: 200}]
treeMap(dataArray, ['state', 'year'], ['people']) will generate
(indentation indicates node tree):
{'name': 'All', 'people': 800}
{'name': 'California', 'people': 400}
{'name': '2009', 'people': 200 }
{'name': '2008', 'people': 200 }
{'name': 'Oregon', 'people': 400 }
{'name': '2009', 'people': 400 }
Metrics will sum by default.
You can perform different calculations on the metrics using flare query expressions.
import flare.query.methods. treeMap(dataArray, ['state', 'year'],
['people',
{avginc: weightedavg('avg_income', 'people')]
{'name': 'All', 'people': 800, 'avginc': 350}
{'name': 'California', 'people': 300, 'avginc': 500}
{'name': '2009', 'people': 100, 'avginc': 600}
{'name': '2008', 'people': 200, 'avginc': 400}
{'name': 'Oregon', 'people': 400, 'avginc': 200}
{'name': '2009', 'people': 400, 'avginc': 200}
Parameters
dataArray:Array — the source array containing objects
|
|
levels:Array — an array of treemap levels to generate
|
|
metrics:Array — the metrics to create, these can be strings or flare query expressions
if strings, the value will be summed across child nodes
|
|
rowFilter:Function (default = null) — an optional filter function that takes a row and returns boolean
|
Tree |
| wordTree | () | method |
public static function wordTree(arr:Array, rootword:String = "hotels", reverse:Boolean = true, addTerminator:Boolean = false, removeStartEnd:Boolean = true, coalesceNodes:Boolean = true, delimiter:String = " "):TreeGenerates a word tree structure from an array of objects.
Parametersarr:Array — the source array
|
|
rootword:String (default = "hotels") — the word to use as the root of the tree
|
|
reverse:Boolean (default = true) — calculate the wordtree forwards or backwards
|
|
addTerminator:Boolean (default = false) — add "START" and "END" terminators at the end of phrases
|
|
removeStartEnd:Boolean (default = true) — remove terminators after generating trees if the terminator is
the only child of a node
|
|
coalesceNodes:Boolean (default = true) — group nodes that contain only a single child
|
|
delimiter:String (default = " ") — what is the delimiter in the phrases, default is ' '
|
Tree |