There are probably going to be a lot of subgraphs. You can use
the subgraph() method to generate a single subgraph with a given set
of nodes. But you'll have to generate the node sets yourself.
Aric
You can use Sage (http://www.sagemath.org) to do this for networkx
graphs. One of the things that Sage does is wrap networkx graphs with
additional functionality. In fact, you can use Sage to filter the list
for only non-isomorphic subgraphs using NICE, an open-source
implementation of the algorithm in nauty.
You could do the following in Sage:
import networkx
# Get a networkx graph
g=networkx.random_lobster(10,0.3,0.05)
# Convert to a Sage graph
gg = Graph(g)
# Display the graph
show(gg)
# Count the number of combinations of 5 vertices out of the graph
Combinations(gg.vertices(), 5).count()
# Construct a subgraph dictionary. Each key is a canonical string label
for a subgraph.
# Each value is the subgraph. The set of values is the set of
non-isomorphic subgraphs
# with 5 vertices.
subgraphs = {}
for v in Combinations(gg.vertices(), 5):
s = gg.subgraph(v, inplace=False)
# Compute a canonical string for each subgraph
canonical_string = s.canonical_label().graph6_string()
subgraphs[canonical_string] = s
# Convert back to networkx graphs
networkx_subgraphs = [g.networkx_graph() for g in subgraphs.values()]
Thanks,
Jason
--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to networkx-discuss@googlegroups.com.
Visit this group at https://groups.google.com/group/networkx-discuss.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To post to this group, send email to networkx...@googlegroups.com.
Visit this group at https://groups.google.com/group/networkx-discuss.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "networkx-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discu...@googlegroups.com.
To post to this group, send email to networkx...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to networkx-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to networkx-discuss@googlegroups.com.