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)
| 209 | |
| 210 | |
| 211 | def 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 | |
| 231 | def write_file(outfile, nodes, edges, groups, hide_legend=False, |