(tmp_path, edges, name="graph.json")
| 22 | |
| 23 | |
| 24 | def _write(tmp_path, edges, name="graph.json"): |
| 25 | G = nx.Graph() |
| 26 | for n in sorted({n for e in edges for n in e[:2]}): |
| 27 | G.add_node(n, label=f"{n}_fn", source_file=f"{n}.py", source_location="L1", community=0) |
| 28 | data = json_graph.node_link_data(G, edges="links") |
| 29 | data["links"] = [ |
| 30 | {"source": u, "target": v, "relation": rel, "confidence": "EXTRACTED", "context": ctx} |
| 31 | for u, v, rel, ctx in edges |
| 32 | ] |
| 33 | path = tmp_path / name |
| 34 | path.write_text(json.dumps(data)) |
| 35 | return path |
| 36 | |
| 37 | |
| 38 | EDGES = [ |
no test coverage detected