MCPcopy Create free account
hub / github.com/scottrogowski/code2flow / generate_json

Function generate_json

code2flow/engine.py:211–228  ·  view source on GitHub ↗

Generate a json string from nodes and edges See https://github.com/jsongraph/json-graph-specification :param nodes list[Node]: functions :param edges list[Edge]: function calls :rtype: str

(nodes, edges)

Source from the content-addressed store, hash-verified

209
210
211def generate_json(nodes, edges):
212 '''
213 Generate a json string from nodes and edges
214 See https://github.com/jsongraph/json-graph-specification
215
216 :param nodes list[Node]: functions
217 :param edges list[Edge]: function calls
218 :rtype: str
219 '''
220 nodes = [n.to_dict() for n in nodes]
221 nodes = {n['uid']: n for n in nodes}
222 edges = [e.to_dict() for e in edges]
223
224 return json.dumps({"graph": {
225 "directed": True,
226 "nodes": nodes,
227 "edges": edges,
228 }})
229
230
231def write_file(outfile, nodes, edges, groups, hide_legend=False,

Callers 1

write_fileFunction · 0.85

Calls 1

to_dictMethod · 0.45

Tested by

no test coverage detected