Cycles in the category tree are almost always undesirable. MediaWiki should offer a way, at least at the backend, for detection of these cycles.
I have implemented a sample algorithm that could be ported:
- get_edges.sql: Get a list of all parentcat--subcat connections through the database, with only the category page IDs.
- find_cycles.cpp: Use depth-first search to detect the cycles.
- prettify.js: Translate the page IDs to titles. Done here using the API.
This method found over 4100 category cycles on English Wikipedia (which had over 6.8 million parentcat--subcat connections) in less than 20 minutes, when run on the Toolforge grid.