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

simulated annealing directed graph? #22

Open
rsblume opened this issue Apr 4, 2014 · 10 comments
Open

simulated annealing directed graph? #22

rsblume opened this issue Apr 4, 2014 · 10 comments

Comments

@rsblume
Copy link

rsblume commented Apr 4, 2014

Hi team,
I accidentally passed a digraph to mod.simulated_annealing(). The algo is currently churning away without throwing up an warning or error. Is this desirable?

@cindeem
Copy link
Contributor

cindeem commented Apr 7, 2014

Hi Rob,

There is a hidden behavior in networkx

#define directed adj matrix
In [121]: jnk
Out[121]:
array([[ 0., 0., 1.],
[ 0., 0., 0.],
[ 1., 1., 0.]])

create a graph object

In [125]: graph = nx.from_numpy_matrix(jnk)

get back adj matrix

In [126]: nx.adjacency_matrix(graph)
Out[126]:
matrix([[ 0., 0., 1.],
[ 0., 0., 1.],
[ 1., 1., 0.]])

Note it is now undirected.

when you created your graph, if you dont explicitly create a digraph, it
will treat it as undirected.
somewhat unexpected and may be worth adding in an error??

Can you confirm that this is what occurred, or did you explicitly pass a
DiGraph object?

--Cindee

On Fri, Apr 4, 2014 at 4:03 PM, rsblume [email protected] wrote:

Hi team,
I accidentally passed a digraph to mod.simulated_annealing(). The algo is
currently churning away without throwing up an warning or error. Is this
desirable?

Reply to this email directly or view it on GitHubhttps://github.com//issues/22
.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

@rsblume
Copy link
Author

rsblume commented Apr 7, 2014

Hi Cindee:
I passed it a digraph explicitly:
from my notebook:
In [4]:
#load data
filestub=('C:\Users\Robert\gitrepos\cocomac-tools-rsblume\applications\ModhaSingh_PFC\modha\lowest_full_g.pck')
whole_low=pickle.load(open(filestub, "rb"))

In [9]: whole_low
Out[9]: <networkx.classes.digraph.DiGraph at 0x5c1ed30>

In [10]: whole_low_sim_part=mod.simulated_annealing(whole_low)

it produced an output.... seems funky... 268 nodes in 1 module and 3 in the second but could be my data.

@cindeem
Copy link
Contributor

cindeem commented Apr 7, 2014

okay...

the result should be funky, do not trust it...
I will add an exception when a directed graph is passed, I do not think the
algorithm can support it....

im meetings most of today will try to send a fix this afternoon/evening
--Cindee

On Mon, Apr 7, 2014 at 10:17 AM, rsblume [email protected] wrote:

Hi Cindee:
I passed it a digraph explicitly:
from my notebook:
In [4]:
#load data

filestub=('C:\Users\Robert\gitrepos\cocomac-tools-rsblume\applications\ModhaSingh_PFC\modha\lowest_full_g.pck')
whole_low=pickle.load(open(filestub, "rb"))

In [9]: whole_low
Out[9]:

In [10]: whole_low_sim_part=mod.simulated_annealing(whole_low)

it produced an output.... seems funky... 268 nodes in 1 module and 3 in
the second but could be my data.

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39757473
.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

@rsblume
Copy link
Author

rsblume commented Apr 7, 2014

I can confirm that the partition of the digraph and the partition of the graph via sim. anneal. are different. I think I am the only user so far who has directed graphs...

@cindeem
Copy link
Contributor

cindeem commented Apr 7, 2014

one quick question,
do the nodes in your graph have self links?
This would be a problem with our current implementation....

On Mon, Apr 7, 2014 at 1:53 PM, rsblume [email protected] wrote:

I can confirm that the partition of the digraph and the partition of the
graph via sim. anneal. are different. I think I am the only user so far who
has directed graphs...

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39782128
.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

@rsblume
Copy link
Author

rsblume commented Apr 7, 2014

no
In [39]: whole_low_undirected.number_of_selfloops()
Out[39]: 0

Thanks

@cindeem
Copy link
Contributor

cindeem commented Apr 8, 2014

Hi Rob,

So without self loops, code as structured should detect communities, Ill
look a little more today to make sure I have not missed anything, but
algorithm should return meaningful communities
C

On Mon, Apr 7, 2014 at 4:58 PM, rsblume [email protected] wrote:

no
In [39]: whole_low_undirected.number_of_selfloops()
Out[39]: 0

Thanks

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39798076
.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

@rsblume
Copy link
Author

rsblume commented Apr 8, 2014

Thanks Cindee,
Sim annealing did return a partition on the directed version of the graph,
but the it was very different than the partition for the undirected. If
memory serves, Newman/modularity was only meant for undirected graphs.
There is another community detection algorithm that Fernando, Dan Bliss and
I played with called Infomap (
http://igraph.sourceforge.net/doc-0.6/html/ch22s08.html) that is meant for
directed graphs. We never got reasonable/usable partitions from infomap
using our graphs. Maybe I am wrong though and modularity is perfectly
appropriate for directed graphs. Thoughts from others in the group?
-Rob

On Tue, Apr 8, 2014 at 7:08 AM, cindeem [email protected] wrote:

Hi Rob,

So without self loops, code as structured should detect communities, Ill
look a little more today to make sure I have not missed anything, but
algorithm should return meaningful communities
C

On Mon, Apr 7, 2014 at 4:58 PM, rsblume [email protected] wrote:

no
In [39]: whole_low_undirected.number_of_selfloops()
Out[39]: 0

Thanks

Reply to this email directly or view it on GitHub<
https://github.com/nipy/brainx/issues/22#issuecomment-39798076>

.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39851760
.

Robert Blumenfeld, Ph.D.
Assistant Adjunct Professor
Brain Circuits Laboratory
University of California, Irvine

@mb3152
Copy link
Contributor

mb3152 commented Apr 8, 2014

Modularity is certainly a reasonable thing for directed graphs, but I don’t think the jury is out on how to handle the directed edges, as directed edges let you measure flow in the graph, which should be taken into account while partitioning the graph; this might get you a more realistic partition than simply treating the graph as undirected and ignoring how the direction of edges dictate flow in the graph. Here are a couple papers proposing methods to handle it. They also discuss overlapping communities, which we might want to start doing as well.

http://arxiv.org/pdf/0904.3940.pdf
http://arxiv.org/pdf/0801.1647.pdf

On Apr 8, 2014, at 9:30 AM, rsblume [email protected] wrote:

Thanks Cindee,
Sim annealing did return a partition on the directed version of the graph,
but the it was very different than the partition for the undirected. If
memory serves, Newman/modularity was only meant for undirected graphs.
There is another community detection algorithm that Fernando, Dan Bliss and
I played with called Infomap (
http://igraph.sourceforge.net/doc-0.6/html/ch22s08.html) that is meant for
directed graphs. We never got reasonable/usable partitions from infomap
using our graphs. Maybe I am wrong though and modularity is perfectly
appropriate for directed graphs. Thoughts from others in the group?
-Rob

On Tue, Apr 8, 2014 at 7:08 AM, cindeem [email protected] wrote:

Hi Rob,

So without self loops, code as structured should detect communities, Ill
look a little more today to make sure I have not missed anything, but
algorithm should return meaningful communities
C

On Mon, Apr 7, 2014 at 4:58 PM, rsblume [email protected] wrote:

no
In [39]: whole_low_undirected.number_of_selfloops()
Out[39]: 0

Thanks

Reply to this email directly or view it on GitHub<
https://github.com/nipy/brainx/issues/22#issuecomment-39798076>

.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39851760
.

Robert Blumenfeld, Ph.D.
Assistant Adjunct Professor
Brain Circuits Laboratory
University of California, Irvine

Reply to this email directly or view it on GitHub.

@cindeem
Copy link
Contributor

cindeem commented Apr 8, 2014

Thanks Maxwell
It is also useful to take a look at
http://journals.aps.org/pre/pdf/10.1103/PhysRevE.80.056117

On Tue, Apr 8, 2014 at 9:44 AM, Maxwell Bertolero
[email protected]:

Modularity is certainly a reasonable thing for directed graphs, but I
don't think the jury is out on how to handle the directed edges, as
directed edges let you measure flow in the graph, which should be taken
into account while partitioning the graph; this might get you a more
realistic partition than simply treating the graph as undirected and
ignoring how the direction of edges dictate flow in the graph. Here are a
couple papers proposing methods to handle it. They also discuss overlapping
communities, which we might want to start doing as well.

http://arxiv.org/pdf/0904.3940.pdf
http://arxiv.org/pdf/0801.1647.pdf

On Apr 8, 2014, at 9:30 AM, rsblume [email protected] wrote:

Thanks Cindee,
Sim annealing did return a partition on the directed version of the
graph,
but the it was very different than the partition for the undirected. If
memory serves, Newman/modularity was only meant for undirected graphs.
There is another community detection algorithm that Fernando, Dan Bliss
and
I played with called Infomap (
http://igraph.sourceforge.net/doc-0.6/html/ch22s08.html) that is meant
for
directed graphs. We never got reasonable/usable partitions from infomap
using our graphs. Maybe I am wrong though and modularity is perfectly
appropriate for directed graphs. Thoughts from others in the group?
-Rob

On Tue, Apr 8, 2014 at 7:08 AM, cindeem [email protected]
wrote:

Hi Rob,

So without self loops, code as structured should detect communities,
Ill
look a little more today to make sure I have not missed anything, but
algorithm should return meaningful communities
C

On Mon, Apr 7, 2014 at 4:58 PM, rsblume [email protected]
wrote:

no
In [39]: whole_low_undirected.number_of_selfloops()
Out[39]: 0

Thanks

Reply to this email directly or view it on GitHub<
https://github.com/nipy/brainx/issues/22#issuecomment-39798076>

.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

Reply to this email directly or view it on GitHub<
https://github.com/nipy/brainx/issues/22#issuecomment-39851760>
.

Robert Blumenfeld, Ph.D.
Assistant Adjunct Professor
Brain Circuits Laboratory

University of California, Irvine

Reply to this email directly or view it on GitHub.

Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-39872056
.

Cindee Madison
Jagust Lab
UC Berkeley
[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants