Open GoogleCodeExporter opened 9 years ago
Original comment by pmatiello
on 17 Nov 2009 at 11:49
Original comment by pmatiello
on 20 Mar 2010 at 10:22
Hi, I have been able to finally put a test function for a graph being a module
of the
given root graph or not. Am attaching the file, can somebody please validate it
for
me?. I believe this should also work for digraphs and hypergraphs. Hoping to
complete
the algorithm in a week's time.
Original comment by anand.ib...@gmail.com
on 23 May 2010 at 9:56
Attachments:
def test_is_sub_graph(rootgr,subgr):
for each in modulegr.nodes():
assert each not in rootgr.nodes()
for each in modulegr.edges():
assert each not in rootgr.edges()
return True
- Should you be asserting that it isn't or that it is in the rootgr? Subgraph
means
that all of the nodes and edges must be in the rootgr
- I think you meant subgr and not modulegr (two locations).
----
neighbors[each] = rootgr.neighbors(each)
- You probably should wrap this in a set, otherwise there are a few spots that
bugs
could arise here. So:
neighbors[each] = set(rootgr.neighbors(each))
----
for i in len(neighbors):
for j in len(neighbors)-1:
neighbors[i] = neighbors[j]
- Since neighbors is a dict, this won't work. You should have:
for set1 in neighbors.values():
for set2 in neighbors.values():
assert set1 == set2
----
With all the fixes, this will only work with undirected graphs. Cheers
Original comment by christian.muise
on 24 May 2010 at 10:35
//Should you be asserting that it isn't or that it is in the rootgr? Subgraph
means
that all of the nodes and edges must be in the rootgr
//- I think you meant subgr and not modulegr (two locations).
My apologies, that was sloppy editing.
//neighbors[each] = set(rootgr.neighbors(each))
The only reason i can think of is set returns a unique list, and some cases are
buggy
to return duplicate nodes for neighbors. Did you have anything else in mind??
// Since neighbors is a dict, this won't work.
You are right. I should have tested a snippet first. Forgot that i am still a
python
newbie.:)
//With all the fixes, this will only work with undirected graphs.
Yep, you are right. I had assumed it would work for digraphs to based on a
misconception of how neighbors() work. Which raised a new question, i put it as
a new
issue here. Issue 76 http://code.google.com/p/python-graph/issues/detail?id=76
Original comment by anand.jeyahar
on 25 May 2010 at 9:44
Sets:
Well if you just return a list of neighbors, then the order of elements in each
list could be different and comparing them may fail.
----
Neighbor Naming:
So if you check out the interface to graph and digraph, 'neighbors' refers to
things that a node connects to, and 'incidents' refers to things connected to
the
node. So I'm not sure there is anything to change for issue 76 other than
possibly a
better name (but this would change an integral part of the API).
Either way, checking for modularity should be done in two phases for digraphs --
one for incidents and one for neighbors. And for hypergraphs you could probably
just
use the 'hyperedges' method, but it will require quite a bit more care. You can
safely ignore hypergraph modular decomp for now since it is a tricky thing to
do, and
requires a solid implementation of mod decomp for simple graphs first.
Cheers
Original comment by christian.muise
on 25 May 2010 at 3:17
An implementation of the modular decomposition algorithm by Tedder et al. (in
Java) is available at http://www.cs.utoronto.ca/~mtedder/. It may be a useful
complement to the paper if someone want to (re)implement this.
Original comment by a3nma...@gmail.com
on 25 Jul 2012 at 8:28
Original issue reported on code.google.com by
christian.muise
on 17 Nov 2009 at 2:21Attachments: