Directed laplacian#741
Directed laplacian#741hagberg merged 22 commits intonetworkx:masterfrom aweinstein:directed_laplacian
Conversation
Code based on https://bitbucket.org/bedwards/networkx-community/src/370bd69fc02f/networkx/algorithms/community/ I refactored Ben Edwards code to one function. This matchs the format of the other functions in the file and allows to import numpy inside the function.
|
This looks good and could use some tests. I see you have modified what @bjedwards to use NumPy eigensolvers instead of the power method. The bigger picture is that we will want to provide sparse matrix versions for all of the functions in networkx/linalg - but that is a bigger project and should be a new issue. |
|
I tried to keep Ben's code as intact as possible. Another option is to use the power method implemented in the Pagerank algorithm. Or may be we can have a parameter that determine what algorithm (power method, eig, eigs) we use to compute the Perron vector. |
|
Let's put your version in (with some tests) and then open another issue to create a sparse matrix version. |
|
I think the plan was to provide a power method version, a numpy version, and a sparse matrix version, then import based on what is available. I think part of the consensus was if you are doing spectral graph theory, you like have numpy or scipy installed. So we could potentially make these modules require numpy and not provide a power method version. Moreover, I don't think numpy is as big of a dependency hassle as it used to be, so I actually wouldn't be opposed to just making it a requirement for networkx, but that is a horse of a different color. |
|
On Sun, Jul 22, 2012 at 4:06 PM, Ben Edwards
I don't mind part of networkx depending on numpy and scipy (as it does One idea that occurred to me is to make all of the linalg functions Anyway - I don't want to get too far off track. I think with some |
|
@hagberg I added some tests for the directed laplacian. |
Addresses networkx#741 There may still be more that need fixing since 1) NumPy and some other optional packages do not yet work with Python3.3 so those tests weren't checked 2) Finding these errors by running the tests is nondeterministic itself (e.g. passes 4 times and fails on the 5th). And inspecting all of the tests by hand is error-prone too.
|
Test results for commit 96c0bd1 merged into master
Not available for testing: |
|
@jtorrents I removed the |
|
Test results for commit 92709b4 merged into master
|
|
Alejandro, Thanks for the quick response. I'm adapting an IPython script for testing I'm preparing a pull request with the adapted script. 2012/8/7 Alejandro Weinstein notifications@github.com
|
networkx/linalg/laplacianmatrix.py
Outdated
There was a problem hiding this comment.
You could use the decorator `require' from networkx/utils/decorators.py
There was a problem hiding this comment.
@Midnighter Done in ede03b2. I also added a not_implemented_for decorator.
The require decorator can also be added to the other functions in laplacianmatrix.py. Is it OK to do it in this PR, or is it better to modify this in another one?
|
NetworkX: Test results for pull request #741 (aweinstein 'directed_laplacian' branch)
|
|
I can't seem to figure out how to merge this correctly (which is likely my inexperience with git). @aweinstein can you look at it? I'd like to include this code for the networkx-1.8 release. |
Fix missing SkipTest import in utils tests
|
@hagberg I can help, but I don't know exactly how. Is it enough if I figure it out how to merge this into my master branch? |
|
I think if you can rebase your changes on the latest master then it would work. |
Code based on https://bitbucket.org/bedwards/networkx-community/src/370bd69fc02f/networkx/algorithms/community/ I refactored Ben Edwards code to one function. This matchs the format of the other functions in the file and allows to import numpy inside the function.
|
@hagberg I did the rebase and fixed some conflicts. Please let me know if this fixed the problem. |
|
Looks good, thanks! I'll review it and do the merge if it all is OK. |
|
NetworkX: Test results for pull request #741 (aweinstein 'directed_laplacian' branch)
|
|
I added some updates in #811 to address some formatting and naming issues. |
|
Question: Shouldn't the directed_laplacian_matrix function be a normalized_directed_laplacian_matrix function? For a directed_laplacian_matrix the combinatorial (non normalized) formula should be used What do you people think about this modification? I am also new to Github, so sorry if there is another way to have you notice this. |
|
Hi @antoniopugliese, thanks for contributing. Can you please create a new issue containing your question so that we can track its resolution separately from this pull request? (Feel free to reference this pull request when you create the issue.) |
|
@antoniopugliese @jfinkels We used the definition given in the paper Fan Chung (2005). Laplacians and the Cheeger inequality for directed graphs. Annals of Combinatorics, 9(1), 2005 (available here http://www.math.ucsd.edu/~fan/wp/dichee.pdf). This paper just call it "Laplacian". I would call a function returning L = \Phi - (\Phi P + P^T \Phi) / 2 |
|
@aweinstein @jfinkels I like the |
I added a function to get the laplacian of a directed graph. It is based on Ben Edwards' code.