Repository navigation
Description
Summary
When two distinct communities receive the same label, to_wiki correctly writes two article files (Name.md and Name_2.md), but index.md links both rows to Name.md. Name_2.md is written and then unreachable — nothing in the wiki links to it.
No data is lost; the articles are on disk. The problem is navigational: the index shows two rows with different node counts pointing at one page, and an agent crawling from index.md (the documented entry point) can never reach the second community.
Repro
graphify 0.9.20, Python 3.14, networkx louvain fallback (graspologic not installed).
import networkx as nx, pathlib
from graphify.wiki import to_wiki
G = nx.Graph()
G.add_edges_from([("a1","a2"),("a2","a3"),("b1","b2"),("b2","b3")])
communities = {0: ["a1","a2","a3"], 1: ["b1","b2","b3"]}
labels = {0: "Shared Name", 1: "Shared Name"} # distinct communities, same label
to_wiki(G, communities, "wiki_repro", community_labels=labels)
print("files:", sorted(p.name for p in pathlib.Path("wiki_repro").glob("*.md")))
for ln in pathlib.Path("wiki_repro/index.md").read_text().splitlines():
if ln.startswith("- [Shared Name]"): print(" ", ln)Output:
files: ['Shared_Name.md', 'Shared_Name_2.md', 'index.md']
- [Shared Name](Shared_Name.md) — 3 nodes
- [Shared Name](Shared_Name.md) — 3 nodes
Expected: the second row links to Shared_Name_2.md.
Root cause
Two parallel maps are built, and the index uses the wrong one.
wiki.py:305-309 — articles get a genuinely unique slug per community id, but the resolver is keyed by label, so the second community's slug never enters it:
for cid in communities:
label = labels.get(cid, f"Community {cid}")
slug = _unique_slug(_safe_filename(label))
community_slugs[cid] = slug # unique per cid -- correct
resolver.setdefault(label, slug) # label -> slug, first winswiki.py:324 writes each article under community_slugs[cid], which is why both files exist and are correct.
wiki.py:194 builds the index rows through the label-keyed resolver instead:
lines.append(f"- {_md_link(label, resolver)} — {len(nodes)} nodes")_md_link(label, resolver) looks up by label, so both rows resolve to the first slug.
The setdefault is deliberate (the comment at wiki.py:298-301 notes it preserves filename-assignment order for the case-collision dedup) — the issue is only that the index consumes resolver when it already has the cid in hand.
Suggested fix
_index_md already iterates communities.items() and has cid. Passing community_slugs and linking by cid would resolve it without touching resolver or the dedup ordering:
# _index_md(..., community_slugs)
slug = community_slugs[cid]
lines.append(f"- [{label}]({quote(slug)}.md) — {len(nodes)} nodes")God-node articles at wiki.py:315-317 use the same resolver.setdefault pattern and look like they'd collide the same way, though I didn't reproduce that path.
Impact in practice
On a 12,398-node / 871-community graph, LLM-generated labels collided on 2 names in one labeling run and 20 in another — same graph, same partition, just naming variance between runs. So the orphan count is not stable, and on an unlucky run a couple dozen communities drop out of navigation entirely.
Activity
Heratiki commentedon Aug 24, 2026
Followed up on the god-node path I flagged as unverified at the end of this issue: it does collide the same way, reproduced and filed as #3033.
Both are the residual half of #497 — that fix's
_unique_slugcorrectly stopped the file overwrites (files are written, distinct, and correct in both paths); what survived is the index resolving links by label instead of by the slug it already has in hand.rohit-jsfreaky commentedon Aug 25, 2026
Root cause is in the index rather than the writer:
to_wikialready gives each community its own slug (community_slugs), but_index_mdre-derives the link target from the label -> slugresolver, which is built withsetdefault— so the first "Shared Name" wins and both rows getShared_Name.md.Fix passes the slugs the articles were actually written under into
_index_mdand links by those. #3033 is the same defect in the god-node loop, so both are in one PR. Your repro now printsShared_Name_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