Instructions:
- Create an array of Node objects. Each Node should at least have the connections (array of Connection objects) attribute defined. Each Connection should at least have the targetNode<.i> attribute defined, which refers to a Node object.
- Create an instance of GridLayout, providing an array of nodes as the only argument for the constructor.
- Call the generate3DLayout method of a GridLayout instance. The method takes no arguments and returns the array of Node objects with position attribute. The position attribute is an object with the fields: x, y, z. The original array of Node objects will be modified.
Example:
var nodes = [];
for (var n = 0; n < 5; n++) {
nodes.push(new GridLayout.Node());
}
GridLayout.connectNodes(nodes[0], nodes[1]);
GridLayout.connectNodes(nodes[2], nodes[3]);
GridLayout.connectNodes(nodes[1], nodes[2]);
GridLayout.connectNodes(nodes[0], nodes[3]);
var gridLayout = new GridLayout(nodes);
console.log(gridLayout.generate3DLayout()); //log results