A directed acyclic graph (DAG). In Verge3D this structure is used to define the hierarchy of node-based materials.


DiGraph(V : Integer)

Create a new graph of the size V.


.V : Integer

Graph size.

.adjList : Array

Graph adjacency list.

.nodeInfo : Array

Data attached to graph nodes.

.edges : Object

Graph edges.


.addNode(nodeInfo : Object)

Add a new node to the graph and attach .nodeInfo data to it.


Remove all nodes and edges from the graph.

.addEdge(edge : Edge)

Add an edge to the graph.

.addNewEdge(v : Integer, w : Integer) → Edge

Add a new edge to the graph which connects nodes v and w.

.removeEdge(v : Integer, w : Integer)

Remove an edge from the graph which connects nodes v and w.

.edge(v : Integer, w : Integer) → Edge

Return an edge which connects nodes v and w. Return null if no such edge is found.

.adj(v : Integer) → Integer

Return node adjacent to node v.

.node(v : Integer) → Object

Return node info data for node v.

.nodeINdex(nodeInfo : Object) → Integer

Return the index of the node which has the passed .nodeInfo data.

.reverse() → DiGraph

Return a new graph which has all edges reversed. The source graph remains intact.

.len() → DiGraph

Return graph length.

.findInEdges(v : Integer) → Array

Return input edges for node v.

.findOutEdges(v : Integer) → Array

Return output edges for node v.

.disconnect(v : Integer, removeNode : Boolean)

Disconnect node v from the graph. If removeNode=false (default) leave the disconnected node inside the graph. If removeNode=true remove the node (with its data) as well.

.insert(G : DiGraph, edgesInG : Array, edgesOutG : Array, copyNodeCb : Function, copyEdgeCb : Function)

Insert a G subgraph into the graph. The edgesInG and edgesOutG arrays represent input and output edges which will be used to connect the subgraph. Optional callbacks copyNodeCb and copyEdgeCb are executed per node/edge inserted to the graph.

.vis(labelCallback : Function)

Convert the graph to the DOT (Graphviz) format and print to the browser console. Optional labelCallback is used to assign labels for the printed graph nodes. It accepts node index and node info as parameters.


For more info on how to obtain the source code of this module see this page.