diff --git a/Jakefile.js b/Jakefile.js
index 332dd688..80a725f8 100644
--- a/Jakefile.js
+++ b/Jakefile.js
@@ -81,8 +81,10 @@ task('build', {async: true}, function () {
'./src/graph/Groups.js',
'./src/graph/Images.js',
'./src/graph/graphMixins/physics/PhysicsMixin.js',
+ './src/graph/graphMixins/physics/HierarchialRepulsion.js',
'./src/graph/graphMixins/physics/BarnesHut.js',
'./src/graph/graphMixins/physics/Repulsion.js',
+ './src/graph/graphMixins/HierarchicalLayoutMixin.js',
'./src/graph/graphMixins/ManipulationMixin.js',
'./src/graph/graphMixins/SectorsMixin.js',
'./src/graph/graphMixins/ClusterMixin.js',
diff --git a/docs/graph.html b/docs/graph.html
index e5e73bd5..e8c402ac 100644
--- a/docs/graph.html
+++ b/docs/graph.html
@@ -59,6 +59,7 @@
- fixed |
+ allowedToMove |
Boolean |
- false |
- If fixed is true, then the node will not move from its supplied position.
+ | true |
+ If allowedToMove is false, then the node will not move from its supplied position.
If only an x position has been supplied, it is only fixed in the x-direction.
The same holds for y. If both x and y have been defined, the node will not move. |
@@ -335,8 +336,15 @@ var nodes = [
- fixed |
+ allowedToMove |
Boolean |
false |
- If fixed is true, then the node will not move from its supplied position.
+ | If allowedToMove is false, then the node will not move from its supplied position.
If only an x position has been supplied, it is only fixed in the x-direction.
The same holds for y. If both x and y have been defined, the node will not move. |
@@ -876,6 +884,12 @@ var options = {
+ The graph can be used to display nodes in a hierarchical way. This can be determined automatically, based on the amount of edges connected to each node, or defined by the user.
+ If the user wants to manually determine the hierarchy, each node has to be supplied with a level (from 0 being heighest to n). The automatic method
+ is shown in example 23 and the user-defined method is shown in example 24.
+ This layout method does not support smooth curves or clustering. It automatically turns these features off.
+
+
+
Graph supports the following methods.
diff --git a/examples/graph/17_network_info.html b/examples/graph/17_network_info.html
index ca97d75a..0b7e033f 100644
--- a/examples/graph/17_network_info.html
+++ b/examples/graph/17_network_info.html
@@ -96,11 +96,11 @@
var x = - mygraph.clientWidth / 2 + 50;
var y = - mygraph.clientHeight / 2 + 50;
var step = 70;
- nodes.push({id: 1000, x: x, y: y, label: 'Internet', group: 'internet', value: 1, fixed:true});
- nodes.push({id: 1001, x: x, y: y + step, label: 'Switch', group: 'switch', value: 1, fixed:true});
- nodes.push({id: 1002, x: x, y: y + 2 * step, label: 'Server', group: 'server', value: 1, fixed:true});
- nodes.push({id: 1003, x: x, y: y + 3 * step, label: 'Computer', group: 'desktop', value: 1, fixed:true});
- nodes.push({id: 1004, x: x, y: y + 4 * step, label: 'Smartphone', group: 'mobile', value: 1, fixed:true});
+ nodes.push({id: 1000, x: x, y: y, label: 'Internet', group: 'internet', value: 1});
+ nodes.push({id: 1001, x: x, y: y + step, label: 'Switch', group: 'switch', value: 1});
+ nodes.push({id: 1002, x: x, y: y + 2 * step, label: 'Server', group: 'server', value: 1});
+ nodes.push({id: 1003, x: x, y: y + 3 * step, label: 'Computer', group: 'desktop', value: 1});
+ nodes.push({id: 1004, x: x, y: y + 4 * step, label: 'Smartphone', group: 'mobile', value: 1});
// create a graph
var container = document.getElementById('mygraph');
diff --git a/examples/graph/19_scale_free_graph_clustering.html b/examples/graph/19_scale_free_graph_clustering.html
index 640e2207..ef3de8cd 100644
--- a/examples/graph/19_scale_free_graph_clustering.html
+++ b/examples/graph/19_scale_free_graph_clustering.html
@@ -107,7 +107,7 @@
- This example shows therandomly generated
scale-free-graph set of nodes and connected edges from example 2.
+ This example shows the randomly generated
scale-free-graph set of nodes and connected edges from example 2.
By clicking the checkbox you can turn clustering on and off. If you increase the number of nodes to
a value higher than 100, automatic clustering is used before the initial draw (assuming the checkbox is checked).
diff --git a/examples/graph/23_hierarchical_layout.html b/examples/graph/23_hierarchical_layout.html
new file mode 100644
index 00000000..5923e21e
--- /dev/null
+++ b/examples/graph/23_hierarchical_layout.html
@@ -0,0 +1,113 @@
+
+
+
+
Graph | Random nodes
+
+
+
+
+
+
+
+
+
+
Hierarchical Layout - Scale-Free-Graph
+
+ This example shows the randomly generated scale-free-graph set of nodes and connected edges from example 2.
+ In this example, hierarchical layout has been enabled and the vertical levels are determine automatically.
+
+
+
+
+
+
+
+
+
+
diff --git a/examples/graph/24_hierarchical_layout_userdefined.html b/examples/graph/24_hierarchical_layout_userdefined.html
new file mode 100644
index 00000000..0605485a
--- /dev/null
+++ b/examples/graph/24_hierarchical_layout_userdefined.html
@@ -0,0 +1,139 @@
+
+
+
+
Graph | Random nodes
+
+
+
+
+
+
+
+
+
+
Hierarchical Layout - User-defined
+
+ This example shows a user-defined hierarchical layout. If the user defines levels for nodes but does not do so for all nodes, an alert will show up and hierarchical layout will be disabled. Either all or none can be defined.
+
+
+
+
+
+
+
+
diff --git a/examples/graph/index.html b/examples/graph/index.html
index 4b38888d..db69b9ca 100644
--- a/examples/graph/index.html
+++ b/examples/graph/index.html
@@ -34,6 +34,8 @@
20_navigation.html
21_data_manipulation.html
22_les_miserables.html
+
23_hierarchical_layout.html
+
24_hierarchical_layout_predefined.html
graphviz_gallery.html
diff --git a/img/gallery/graph/18_fully_random_nodes_clustering.png b/img/gallery/graph/18_fully_random_nodes_clustering.png
new file mode 100644
index 00000000..6356994e
Binary files /dev/null and b/img/gallery/graph/18_fully_random_nodes_clustering.png differ
diff --git a/img/gallery/graph/19_scale_free_graph_clustering.png b/img/gallery/graph/19_scale_free_graph_clustering.png
new file mode 100644
index 00000000..70505e2b
Binary files /dev/null and b/img/gallery/graph/19_scale_free_graph_clustering.png differ
diff --git a/img/gallery/graph/20_navigation.png b/img/gallery/graph/20_navigation.png
new file mode 100644
index 00000000..3cc4dc06
Binary files /dev/null and b/img/gallery/graph/20_navigation.png differ
diff --git a/img/gallery/graph/21_data_manipulation.png b/img/gallery/graph/21_data_manipulation.png
new file mode 100644
index 00000000..26e9f1d3
Binary files /dev/null and b/img/gallery/graph/21_data_manipulation.png differ
diff --git a/img/gallery/graph/22_les_miserables.png b/img/gallery/graph/22_les_miserables.png
new file mode 100644
index 00000000..e09225c4
Binary files /dev/null and b/img/gallery/graph/22_les_miserables.png differ
diff --git a/img/gallery/graph/23_hierarchical_layout.png b/img/gallery/graph/23_hierarchical_layout.png
new file mode 100644
index 00000000..7d5035ed
Binary files /dev/null and b/img/gallery/graph/23_hierarchical_layout.png differ
diff --git a/img/gallery/graph/24_hierarchical_layout_predefined.png b/img/gallery/graph/24_hierarchical_layout_predefined.png
new file mode 100644
index 00000000..3499e989
Binary files /dev/null and b/img/gallery/graph/24_hierarchical_layout_predefined.png differ
diff --git a/index.html b/index.html
index a0c18d7f..8e7be2a1 100644
--- a/index.html
+++ b/index.html
@@ -268,6 +268,49 @@ The source code of the examples can be found in the