MCPcopy Create free account
hub / github.com/Graphify-Labs/graphify / _graph_json

Function _graph_json

tests/test_export_direction.py:33–66  ·  view source on GitHub ↗

The `graphify extract` shape: undirected flag, direction in arc order. ``callee`` precedes ``caller`` in the node list, the exact condition under which an undirected load flips the edge. ``helper`` -> ``util`` is listed source-first, so it survives either way and guards against over-cor

(tmp_path: Path)

Source from the content-addressed store, hash-verified

31
32
33def _graph_json(tmp_path: Path) -> Path:
34 """The `graphify extract` shape: undirected flag, direction in arc order.
35
36 ``callee`` precedes ``caller`` in the node list, the exact condition under
37 which an undirected load flips the edge. ``helper`` -> ``util`` is listed
38 source-first, so it survives either way and guards against over-correction.
39 """
40 out = tmp_path / "graphify-out"
41 out.mkdir()
42 data = {
43 "directed": False,
44 "multigraph": False,
45 "graph": {},
46 "nodes": [
47 {"id": "callee", "label": "callee()", "file_type": "code", "source_file": "a.py", "community": 0},
48 {"id": "caller", "label": "caller()", "file_type": "code", "source_file": "a.py", "community": 0},
49 {"id": "helper", "label": "helper()", "file_type": "code", "source_file": "a.py", "community": 0},
50 {"id": "util", "label": "util()", "file_type": "code", "source_file": "a.py", "community": 0},
51 # legacy canonicalized link: arc flipped, markers carry the truth
52 {"id": "legacy_b", "label": "legacy_b()", "file_type": "code", "source_file": "a.py", "community": 0},
53 {"id": "legacy_a", "label": "legacy_a()", "file_type": "code", "source_file": "a.py", "community": 0},
54 ],
55 "links": [
56 {"source": "caller", "target": "callee", "relation": "calls", "confidence": "EXTRACTED"},
57 {"source": "helper", "target": "util", "relation": "calls", "confidence": "EXTRACTED"},
58 {"source": "legacy_b", "target": "legacy_a", "_src": "legacy_a", "_tgt": "legacy_b",
59 "relation": "calls", "confidence": "EXTRACTED"},
60 ],
61 }
62 p = out / "graph.json"
63 p.write_text(json.dumps(data))
64 (out / ".graphify_analysis.json").write_text(json.dumps(
65 {"communities": {"0": ["callee", "caller", "helper", "util", "legacy_a", "legacy_b"]}}))
66 return p
67
68
69TRUE_ARCS = {("caller", "callee"), ("helper", "util"), ("legacy_a", "legacy_b")}

Calls

no outgoing calls

Tested by

no test coverage detected