diff --git a/graphify/analyze.py b/graphify/analyze.py index d9bd479f..a47d82aa 100644 --- a/graphify/analyze.py +++ b/graphify/analyze.py @@ -51,7 +51,7 @@ def god_nodes(G: nx.Graph, top_n: int = 10) -> list[dict]: result.append({ "id": node_id, "label": G.nodes[node_id].get("label", node_id), - "edges": deg, + "degree": deg, }) if len(result) >= top_n: break diff --git a/graphify/report.py b/graphify/report.py index 180233d2..5ebd2ea6 100644 --- a/graphify/report.py +++ b/graphify/report.py @@ -72,7 +72,7 @@ def generate( "## God Nodes (most connected - your core abstractions)", ] for i, node in enumerate(god_node_list, 1): - lines.append(f"{i}. `{node['label']}` - {node['edges']} edges") + lines.append(f"{i}. `{node['label']}` - {node['degree']} edges") lines += ["", "## Surprising Connections (you probably didn't know these)"] if surprise_list: diff --git a/graphify/serve.py b/graphify/serve.py index d1f1960d..361dec3c 100644 --- a/graphify/serve.py +++ b/graphify/serve.py @@ -295,7 +295,7 @@ def _tool_god_nodes(arguments: dict) -> str: from .analyze import god_nodes as _god_nodes nodes = _god_nodes(G, top_n=int(arguments.get("top_n", 10))) lines = ["God nodes (most connected):"] - lines += [f" {i}. {n['label']} - {n['edges']} edges" for i, n in enumerate(nodes, 1)] + lines += [f" {i}. {n['label']} - {n['degree']} edges" for i, n in enumerate(nodes, 1)] return "\n".join(lines) def _tool_graph_stats(_: dict) -> str: diff --git a/graphify/wiki.py b/graphify/wiki.py index 898a8ec5..732444f7 100644 --- a/graphify/wiki.py +++ b/graphify/wiki.py @@ -154,7 +154,7 @@ def _index_md( if god_nodes_data: lines += ["## God Nodes", "(most connected concepts — the load-bearing abstractions)", ""] for node in god_nodes_data: - lines.append(f"- [[{node['label']}]] — {node['edges']} connections") + lines.append(f"- [[{node['label']}]] — {node['degree']} connections") lines.append("") lines += [ diff --git a/tests/test_analyze.py b/tests/test_analyze.py index 2d496139..1017da8b 100644 --- a/tests/test_analyze.py +++ b/tests/test_analyze.py @@ -23,7 +23,7 @@ def test_god_nodes_returns_list(): def test_god_nodes_sorted_by_degree(): G = make_graph() result = god_nodes(G, top_n=10) - degrees = [r["edges"] for r in result] + degrees = [r["degree"] for r in result] assert degrees == sorted(degrees, reverse=True) @@ -32,7 +32,7 @@ def test_god_nodes_have_required_keys(): result = god_nodes(G, top_n=1) assert "id" in result[0] assert "label" in result[0] - assert "edges" in result[0] + assert "degree" in result[0] def test_surprising_connections_cross_source_multi_file(): diff --git a/tests/test_hypergraph.py b/tests/test_hypergraph.py index dc7d40ae..dda8ac79 100644 --- a/tests/test_hypergraph.py +++ b/tests/test_hypergraph.py @@ -166,7 +166,7 @@ def _make_report(G): communities = {0: list(G.nodes())} cohesion = {0: 1.0} labels = {0: "All"} - gods = [{"label": "BasicAuth", "edges": 2}] + gods = [{"label": "BasicAuth", "degree": 2}] surprises = [] return generate(G, communities, cohesion, labels, gods, surprises, SAMPLE_DETECTION, {"input": 10, "output": 5}, ".") diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 9f7335b6..ce6055d8 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -51,7 +51,7 @@ def run_pipeline(tmp_path: Path) -> dict: # Step 5: analyze gods = god_nodes(G) assert len(gods) > 0 - assert all("id" in g and "edges" in g for g in gods) + assert all("id" in g and "degree" in g for g in gods) surprises = surprising_connections(G, communities) assert isinstance(surprises, list) diff --git a/tests/test_wiki.py b/tests/test_wiki.py index 3b29cf5b..48335958 100644 --- a/tests/test_wiki.py +++ b/tests/test_wiki.py @@ -20,7 +20,7 @@ def _make_graph(): COMMUNITIES = {0: ["n1", "n2"], 1: ["n3", "n4"]} LABELS = {0: "Parsing Layer", 1: "Rendering Layer"} COHESION = {0: 0.85, 1: 0.72} -GOD_NODES = [{"id": "n1", "label": "parse", "edges": 2}] +GOD_NODES = [{"id": "n1", "label": "parse", "degree": 2}] def test_to_wiki_writes_index(tmp_path): @@ -105,7 +105,7 @@ def test_god_node_article_links_community(tmp_path): def test_to_wiki_skips_missing_god_node_ids(tmp_path): """God node with bad ID should not crash.""" G = _make_graph() - bad_gods = [{"id": "nonexistent", "label": "ghost", "edges": 99}] + bad_gods = [{"id": "nonexistent", "label": "ghost", "degree": 99}] n = to_wiki(G, COMMUNITIES, tmp_path, community_labels=LABELS, god_nodes_data=bad_gods) # 2 communities + 0 god nodes (nonexistent skipped) = 2 assert n == 2