Skip to content
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

Merged
merged 8 commits into from
May 26, 2014

Conversation

chebee7i
Copy link
Member

@chebee7i chebee7i commented May 9, 2014

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).

@argriffing
Copy link

Here's a migrated trac ticket #639 for http://en.wikipedia.org/wiki/Edmonds'_algorithm related to arborescences.

@chebee7i
Copy link
Member Author

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.

@argriffing
Copy link

I'm preparing another pull request which builds on this code.
I was planning to add unit tests in that PR

Is this still happening, or would it be worth separating out the fix and unit test for just the is_tree function to resolve #1144?

@chebee7i
Copy link
Member Author

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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if len(G) == 0

@hagberg
Copy link
Member

hagberg commented May 26, 2014

The documentation is clear to me.

chebee7i added a commit that referenced this pull request May 26, 2014
Generalize is_tree and is_forest to directed graphs. Also fixes #1144.
@chebee7i chebee7i merged commit ea6ff80 into networkx:master May 26, 2014
@hagberg hagberg added this to the networkx-1.9 milestone May 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants