-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalize is_tree and is_forest to directed graphs. #1145
Conversation
Generalize is_tree(), is_forest() to handle directed graphs.
Here's a migrated trac ticket #639 for http://en.wikipedia.org/wiki/Edmonds'_algorithm related to arborescences. |
Ah great. I'll attach the stuff to that. I didn't implement the method from Gabow, Galil, Spencer, Tarjan...mostly because Edmond's algorithm seemed easier to implement. Still though, NetworkX data structures require a bit of work for algorithm like these. This is, in part, because edges are second class citizens in the primary graph classes. Add to that time-varying graphs that need to maintain edge identity, and it can be a bit painful. |
Is this still happening, or would it be worth separating out the fix and unit test for just the |
This is ready for merging, just needs another eye on it to for suggestions/corrections/etc. Take time to read the module docstring. From what I can see, there are two conventions in the literature. I tried to explain what these conventions were and which one NetworkX is using. |
""" | ||
for graph in nx.connected_component_subgraphs(G): | ||
if not nx.is_tree(graph): | ||
n = G.number_of_nodes() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if len(G) == 0
The documentation is clear to me. |
Generalize is_tree and is_forest to directed graphs. Also fixes #1144.
Also add recognition for branchings and arborescences. I'm preparing another pull request which builds on this code. I was planning to add unit tests in that PR (next week).