Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion graphify/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion graphify/report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion graphify/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion graphify/wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 += [
Expand Down
4 changes: 2 additions & 2 deletions tests/test_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand All @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tests/test_hypergraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}, ".")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_wiki.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down