Visual overview of basic graph types generated using NetworkX

Recently, I’ve been working on understanding how graphs can be represented and manipulated in Python. I needed to generate a reasonable random graph and its adjacency matrix in Python, and found the NetworkX package very useful for this purpose.

Since I am somewhat naïve about graph theory, I found it useful to construct a visual overview of the different types of basic graphs that we are able to generate using NetworkX. I experimented with the arguments to better interpret the properties of these graphs.

Sharing this for future reference, and to help anyone just starting out with graphs in Python.

balanced_tree(r, h[, create_using])r = 2 — branching factor
h = 3 — height
barbell_graph(m1, m2[, create_using])m1 = 4 — no. of nodes in each identical, complete sub-graph
m2 = 2 — no. of nodes in connecting path
complete_graph(n[, create_using])n = 10 — no. of nodes
complete_multipartite_graph(*subset_sizes)subset sizes = 1, 2, 3

circular_ladder_graph(n[, create_using])n = 6 — length of ladder (3 creates an “extruded triangle”, 4 an “extruded square”, 6 an “extruded hexagon” and so on)

circulant_graph(n, offsets[, create_using])n = 10 — no. of nodes
offsets = [1,2]
cycle_graph(n[, create_using])n = 5 — no. of nodes

dorogovtsev_goltsev_mendes_graph(n[, …])n = 3 — number of nodes added to initial triangle

empty_graph([n, create_using, default])
full_rary_tree(r, n[, create_using])Here I chose r and n in order to recreate the diamond tetrahedral structure.
r = 4 – branching factor of the tree
n = 17 – number of nodes in the tree

ladder_graph(n[, create_using])n = 7 — length of ladder
lollipop_graph(m, n[, create_using])m = — no. of nodes in complete graph
n = — path length

null_graph([create_using])
path_graph(n[, create_using])n = 7 — path length

star_graph(n[, create_using])n = 10 — no. of points in star graph

trivial_graph([create_using])Trivial!

turan_graph(n, r)n = 5 – no. of nodes
r = 2 – no. of partitions

wheel_graph(n[, create_using])
0