Skip to content

Modularity matrix#1448

Merged
chebee7i merged 10 commits intonetworkx:masterfrom
jg-you:modularity-matrix
Apr 9, 2015
Merged

Modularity matrix#1448
chebee7i merged 10 commits intonetworkx:masterfrom
jg-you:modularity-matrix

Conversation

@jg-you
Copy link
Copy Markdown
Contributor

@jg-you jg-you commented Apr 8, 2015

This pull request implements the modularity matrix (MEJ Newman, 2006, PNAS) with associated test suites and spectrum operations.
I did not implement any weighted/multigraph/directed methods since there is no consensus on the definition, to the best of my knowledge.

This is my first contribution to NetworkX, comments are more than welcome.

@jg-you
Copy link
Copy Markdown
Contributor Author

jg-you commented Apr 8, 2015

Had to use from __future__ import division.
This pull request now works both with python2.7 and python3.4.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Given the @not_implemented_for decorators, what does this note mean. Similarly with modularity_spectrum?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oops, it slipped through (I used linalg/laplacianmatrix.py as a base template)
My apologies.

@Midnighter
Copy link
Copy Markdown

I'm sorry if you asked for this functionality before, I must have missed it. Both @bjedwards and myself have implemented the modularity maximization (also for the directed case) before. You can find his GSoC project and my own code.

Both are dated and not fully integrated so it's great that you're issuing this pull request. I don't have the time right now to compare the code but maybe it'll be helpful. Cheers.

@jg-you
Copy link
Copy Markdown
Contributor Author

jg-you commented Apr 8, 2015

Thanks for the answer @Midnighter.
I never asked for that feature before, but merely implemented it straight away!
It was not too complicated :)

As code comparison goes:

The idea behind this pull request is to implement a method that construct the modularity matrix itself, independent of any optimization methods.
Much like the Laplacian matrix, this matrix does not necessarily requires community information to be of any use.
For example, it has seen been the subject of a renewed interest, due to papers that focus on matrix spectrum calculations (e.g. http://arxiv.org/abs/1306.2507 or http://arxiv.org/abs/1208.1275).

I think that the code would fit the present model as is.
My rationale is basically that it sits with the Laplacian matrix related code, which is a very similar concept.
I might be wrong, because I'm not yet fully aware of NetworkX future development targets / philosophy.

While we're discussing this, I can think of some extra features that I could implement if there is some interest:

  • Null model selection (e.g. random graph, spin models, etc.)
  • Directed / weighted extensions. I'd go for the variants that appear in GSoC project.

@chebee7i
Copy link
Copy Markdown
Member

chebee7i commented Apr 9, 2015

I like this. Code is clean and it's standalone. Let's merge now, and you can submit another pull request with additional features. The directed extensions would be nice.

chebee7i added a commit that referenced this pull request Apr 9, 2015
@chebee7i chebee7i merged commit 0669242 into networkx:master Apr 9, 2015
@jg-you jg-you deleted the modularity-matrix branch April 9, 2015 18:27
@jg-you jg-you mentioned this pull request Apr 16, 2015
@jg-you jg-you restored the modularity-matrix branch April 16, 2015 18:31
@jg-you jg-you deleted the modularity-matrix branch April 17, 2015 02:38
@chebee7i chebee7i added this to the networkx-2.0 milestone Apr 17, 2015
@ysitu ysitu modified the milestones: networkx-2.0, networkx-1.10 Apr 27, 2015
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.

4 participants