Skip to content

Feature add: min cycle basis - #1649

Closed
debsankha wants to merge 1 commit into
networkx:masterfrom
debsankha:feature-add-mcb
Closed

debsankha wants to merge 1 commit into
networkx:masterfrom
debsankha:feature-add-mcb

Conversation

@debsankha

Copy link
Copy Markdown

I have added a function to compute minimum weight cycle basis for an undirected graph following de Pina's algorithm.

@jfinkels

jfinkels commented Jul 9, 2015

Copy link
Copy Markdown
Contributor

Maybe this should live in the networkx.algorithms.cycles module, which already contains functions for computing cycle bases, instead of creating a new networkx.algorithms.minimum_cycles module?

@hagberg

hagberg commented Jul 9, 2015

Copy link
Copy Markdown
Member

This looks very interesting. Thanks for the contribution. It makes sense to put it in network.algorithm.cycles as @jfinkels suggests.

It looks like the test failure is due to some travis issue and not this code - @chebee7i it is suggesting we update from the "legacy infrastructure" http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade

@debsankha

Copy link
Copy Markdown
Author

Hi @jfinkels @hagberg , thanks a lot for your comments. Since I have never contributed here, I was a bit hesistant to modify an existing module, but I completely agree to your suggestion.

I have moved the code to network.algorithm.cycles.

Comment thread networkx/algorithms/cycles.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would rather see this as return sum((_min_cycle_basis(c, weight) for c in nx.connected_component_subgraphs(G)), []), where _min_cycle_basis is the body of the main loop below (that is, the main algorithm when the input is guaranteed to be connected). Makes it clear 1. where the main work is and 2. that this can be trivially parallelized.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I have done as you suggested.

@jfinkels

Copy link
Copy Markdown
Contributor

Code style is starting to look better. You should run flake8 and make the corrections it suggests.

Comment thread networkx/algorithms/cycles.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

remove redundant backslash

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Done

@chebee7i

chebee7i commented Aug 7, 2015

Copy link
Copy Markdown
Member

Oh, I just saw the comment about legacy infrastructure. Are the test failures still an issue?

@chebee7i

chebee7i commented Aug 7, 2015

Copy link
Copy Markdown
Member

(Doesn't appear so)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Inherit from object for Python 2 compatibility purposes: class TestMinimumCycles(object):

@jfinkels

Copy link
Copy Markdown
Contributor

Can you please add a line in the file doc/source/reference/algorithms.cycles.rst corresponding to this function in order to expose the function in the documentation? After that and the changes to the test file, I'm fine with this. The commits should be squashed into one.

@debsankha

Copy link
Copy Markdown
Author

I have implemented those changes.

@jfinkels

Copy link
Copy Markdown
Contributor

Can you please squash these changes into a single commit with a good commit message? git rebase -i master

https://help.github.com/articles/about-git-rebase/

@debsankha

Copy link
Copy Markdown
Author

Thanks for the help with squashing. I have squashed them now.

@jfinkels

Copy link
Copy Markdown
Contributor

Your pull request seems to have gained duplicate files minimum_cycles and test_minimum_cycles?

@debsankha

Copy link
Copy Markdown
Author

Ahh sorry, somehow happened while I was squashing the commits. It is fixed now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants