{"action":"opened","issue":{"url":"https://api.github.com/repos/networkx/networkx/issues/1342","labels_url":"https://api.github.com/repos/networkx/networkx/issues/1342/labels{/name}","comments_url":"https://api.github.com/repos/networkx/networkx/issues/1342/comments","events_url":"https://api.github.com/repos/networkx/networkx/issues/1342/events","html_url":"https://github.com/networkx/networkx/issues/1342","id":55651670,"number":1342,"title":"\"robust\" topological sort (does best it can when there are cycles)","user":{"login":"jason-s","id":738893,"avatar_url":"https://avatars.githubusercontent.com/u/738893?v=3","gravatar_id":"","url":"https://api.github.com/users/jason-s","html_url":"https://github.com/jason-s","followers_url":"https://api.github.com/users/jason-s/followers","following_url":"https://api.github.com/users/jason-s/following{/other_user}","gists_url":"https://api.github.com/users/jason-s/gists{/gist_id}","starred_url":"https://api.github.com/users/jason-s/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jason-s/subscriptions","organizations_url":"https://api.github.com/users/jason-s/orgs","repos_url":"https://api.github.com/users/jason-s/repos","events_url":"https://api.github.com/users/jason-s/events{/privacy}","received_events_url":"https://api.github.com/users/jason-s/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-01-27T17:57:26Z","updated_at":"2015-01-27T17:57:26Z","closed_at":null,"body":"The existing version of networkx raises an exception [if topological_sort is called on a directed graph with cycles](https://networkx.github.io/documentation/latest/reference/generated/networkx.algorithms.dag.topological_sort.html).\r\n\r\nI am not very familiar with graph theory so don't really know how to comment on this, but I am looking for an algorithm that does \"the best it can\", maybe leaving the nodes in a cycle in some order and doing a topological sort on the rest. [This article](http://www.logarithmic.net/pfh/blog/01208083168) allegedly uses an algorithm from Tarjan (which gives me some confidence that it has merit), with a fairly simple Python implementation posted.\r\n\r\nIs there a way you could add a keyword `robust=False` to the `topological_sort()` method, and if `robust` is `True`, use this type of algorithm?"}}