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

Function _make_graph

tests/test_cli_export.py:43–73  ·  view source on GitHub ↗

Build a minimal graph.json + analysis/labels files in tmp_path/graphify-out/.

(tmp_path: Path)

Source from the content-addressed store, hash-verified

41
42
43def _make_graph(tmp_path: Path) -> Path:
44 """Build a minimal graph.json + analysis/labels files in tmp_path/graphify-out/."""
45 out = tmp_path / "graphify-out"
46 out.mkdir()
47
48 extraction = json.loads((FIXTURES / "extraction.json").read_text())
49 from graphify.build import build_from_json
50 from graphify.cluster import cluster, score_all
51 from graphify.analyze import god_nodes, surprising_connections
52 from graphify.export import to_json
53
54 G = build_from_json(extraction)
55 communities = cluster(G)
56 cohesion = score_all(G, communities)
57 gods = god_nodes(G)
58 surprises = surprising_connections(G, communities)
59 labels = {cid: f"Community {cid}" for cid in communities}
60
61 to_json(G, communities, str(out / "graph.json"))
62
63 analysis = {
64 "communities": {str(k): v for k, v in communities.items()},
65 "cohesion": {str(k): v for k, v in cohesion.items()},
66 "gods": gods,
67 "surprises": surprises,
68 }
69 (out / ".graphify_analysis.json").write_text(json.dumps(analysis))
70 (out / ".graphify_labels.json").write_text(
71 json.dumps({str(k): v for k, v in labels.items()})
72 )
73 return out
74
75
76# ── graphify export html ─────────────────────────────────────────────────────

Calls 7

build_from_jsonFunction · 0.90
clusterFunction · 0.90
score_allFunction · 0.90
god_nodesFunction · 0.90
surprising_connectionsFunction · 0.90
to_jsonFunction · 0.90
itemsMethod · 0.45

Tested by

no test coverage detected