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

Function _make_graph

tests/test_cli_export.py:29–59  ·  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

27
28
29def _make_graph(tmp_path: Path) -> Path:
30 """Build a minimal graph.json + analysis/labels files in tmp_path/graphify-out/."""
31 out = tmp_path / "graphify-out"
32 out.mkdir()
33
34 extraction = json.loads((FIXTURES / "extraction.json").read_text())
35 from graphify.build import build_from_json
36 from graphify.cluster import cluster, score_all
37 from graphify.analyze import god_nodes, surprising_connections
38 from graphify.export import to_json
39
40 G = build_from_json(extraction)
41 communities = cluster(G)
42 cohesion = score_all(G, communities)
43 gods = god_nodes(G)
44 surprises = surprising_connections(G, communities)
45 labels = {cid: f"Community {cid}" for cid in communities}
46
47 to_json(G, communities, str(out / "graph.json"))
48
49 analysis = {
50 "communities": {str(k): v for k, v in communities.items()},
51 "cohesion": {str(k): v for k, v in cohesion.items()},
52 "gods": gods,
53 "surprises": surprises,
54 }
55 (out / ".graphify_analysis.json").write_text(json.dumps(analysis))
56 (out / ".graphify_labels.json").write_text(
57 json.dumps({str(k): v for k, v in labels.items()})
58 )
59 return out
60
61
62# ── 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