2

For example, I want to find all the graphlets with 4 nodes. It will give me 11 distinct graphs.Like this. Is there a function or easy way to generate all these graphs in networkx. I am new to networkx so I do not know all of its features.

I am expecting to get all the unique graphs of fixed size n.

SultanOrazbayev
  • 14,900
  • 3
  • 16
  • 46
Some_Guy
  • 21
  • 2

1 Answers1

2

All the graph variations can be generated with networkx using nx.graph_atlas(), see the docs and the official plot example.

By default, this function will generate all graphs that have up to (and including) 6 nodes, so to keep only the four-node graphs an additional condition is needed:

from networkx import graph_atlas_g

four_node_graphs = [g for g in graph_atlas_g() if len(g.nodes())==4]
print(len(four_node_graphs))
# 11
SultanOrazbayev
  • 14,900
  • 3
  • 16
  • 46
  • I have limited knowledge on graph networks and have a project that needs me to use networkx, any suggestions on good tutorial/book I can use to get on top of things quickly? – wwnde Dec 10 '22 at 03:15