Skip to main content
`Ctrl`+`K`

# barbell_graph

barbell_graph(m1, m2, create_using=None)

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

  (`Source code`, `png`)

  Parameters:
    m1 int

      Size of the left and right barbells, must be greater than 2.

    m2 int

      Length of the path connecting the barbells.

    create_using NetworkX graph constructor, optional (default=nx.Graph)

      Graph type to create. If graph instance, then cleared before populated. Only undirected Graphs are supported.

  Returns:
    G NetworkX graph

      A barbell graph.

  Notes

  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.