Repository navigation
Description
Summary
Same residual bug as #3032, but in the god-node path rather than the community path. When two god nodes share a display label — routine when the same class name exists in two modules — to_wiki writes two article files (Label.md and Label_2.md) with correct, distinct content, but the God Nodes section of index.md links both rows to Label.md. Label_2.md is orphaned.
Filed separately from #3032 because it is a different loop and a different index section; a fix to one does not fix the other. Both descend from #497 (closed), whose _unique_slug fix correctly stopped the file overwrites — #497 explicitly listed "two god nodes" and "a community and a god node" as affected. What survived is the index linking, not the file writing.
Repro
graphify 0.9.20, Python 3.14.
import networkx as nx, pathlib
from graphify.wiki import to_wiki
G = nx.Graph()
G.add_edges_from([("mod_a.py::GameState","a1"),("mod_a.py::GameState","a2"),
("mod_b.py::GameState","b1"),("mod_b.py::GameState","b2")])
for n in G: G.nodes[n]["label"] = n.split("::")[-1]
communities = {0: list(G.nodes)}
god = [
{"id": "mod_a.py::GameState", "label": "GameState", "degree": 2},
{"id": "mod_b.py::GameState", "label": "GameState", "degree": 2},
]
to_wiki(G, communities, "wiki_god",
community_labels={0: "Only Community"}, god_nodes_data=god)
print("files:", sorted(p.name for p in pathlib.Path("wiki_god").glob("*.md")))
for ln in pathlib.Path("wiki_god/index.md").read_text().splitlines():
if "connections" in ln: print(" ", ln)Output:
files: ['GameState.md', 'GameState_2.md', 'Only_Community.md', 'index.md']
- [GameState](GameState.md) — 2 connections
- [GameState](GameState.md) — 2 connections
Expected: the second row links to GameState_2.md.
Confirmed the two files are not identical — _unique_slug and the article renderer are both doing the right thing, so this is purely the index's link resolution.
Root cause
Identical shape to #3032. wiki.py:314-317 keeps the unique slug in a local and puts only the label in the resolver:
for node_data in god_nodes_data:
nid = node_data.get("id")
if nid and nid in G:
slug = _unique_slug(_safe_filename(node_data['label']))
god_articles.append((nid, slug)) # unique per node -- correct
resolver.setdefault(node_data['label'], slug) # label -> slug, first winswiki.py:330-332 writes each article from god_articles, which is why both files land correctly. But wiki.py:199 renders the index rows through the label-keyed resolver:
lines.append(f"- {_md_link(node['label'], resolver)} — {node['degree']} connections")Suggested fix
god_articles already carries (node_id, slug) in the same order as god_nodes_data. Passing it into _index_md and linking by slug — rather than by label through resolver — fixes this without touching resolver or the dedup ordering that the wiki.py:298-301 comment depends on.
Impact in practice
Seen on a real 12,398-node graph: the God Nodes list showed GameState twice (1018 and 106 connections) and Entity twice, with every row pointing at the first article. Because god nodes are by definition the most-connected abstractions, the orphaned entry tends to be a load-bearing one.
Activity
rohit-jsfreaky commentedon Aug 25, 2026
Same fix as #3032. You were right that it is a separate loop, but both come down to
_index_mdresolving targets by label through thesetdefaultresolver instead of using the slug each article was actually written under — so it is one change to one function and I have put both in a single PR rather than split it.Your repro now prints
GameState_2.mdon the second row.fix(wiki): link index rows to their own article when labels collide (G…
fix(wiki): link index rows to their own article when labels collide (#…
safishamsi commentedon Oct 12, 2026
Fixed in v0.9.88 (
graphifyy 0.9.88on PyPI) via #3095.fix(wiki): link article bodies by ID