Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

networkx.generators.classic.barbell_graph

barbell_graph(m1, m2, create_using=None)[source]

Return the Barbell Graph: two complete graphs connected by a path.

For \(m1 > 1\) and \(m2 >= 0\).

Two identical complete graphs \(K_{m1}\) form the left and right bells, and are connected by a path \(P_{m2}\).

The 2*m1+m2 nodes are numbered
0, ..., m1-1 for the left barbell, m1, ..., m1+m2-1 for the path, and m1+m2, ..., 2*m1+m2-1 for the right barbell.

The 3 subgraphs are joined via the edges (m1-1, m1) and (m1+m2-1, m1+m2). If m2=0, this is merely two complete graphs joined together.

This graph is an extremal example in David Aldous and Jim Fill’s e-text on Random Walks on Graphs.