I am building a graph using the arbor.js library.
I build my graph using the addNode() and addEdge() functions of arbor.js. And now I would like to retrieve the built graph using something like .toJson() that should be of the following form:
{nodes:{}, edges:{}}
where the nodes attribute contains a mapping of node names to data objects. For example,
{ nodes:{foo:{color:"red", mass:2},
bar:{color:"green"}} }
and the edges attribute contains nested objects to map source identifier to target, then target to edge data object. e.g,
{ edges:{bar:{foo:{similarity:0},
baz:{similarity:.666}} }
I would start with the
eachNode
,eachEdge
,getNodes
andgetEdges
methods, use those to process the entire graph and create a json object using what those methods return. It does not look like there is a built in method to "traverse the graph and build a json object".