3

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}} }
Asimov4
  • 2,776
  • 3
  • 23
  • 38
  • You may want to look the documentation and the source code to find out how the graph data is stored and to decide whether preconversion is needed or not. – Jay Oct 13 '12 at 12:03

1 Answers1

0

I would start with the eachNode, eachEdge, getNodes and getEdges 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".

OpenCoderX
  • 6,180
  • 7
  • 34
  • 61