Function Repository Resource:

BarbellGraph

Source Notebook

Generate a barbell graph

Contributed by: Arnoud Buzing

ResourceFunction["BarbellGraph"][n,m]

generates a barbell graph using size n barbells and a length m connection.

Details

A barbell graph consists of two complete graphs of size n, connected by m intermediate nodes.

Examples

Basic Examples (2) 

Create a Barbell graph of size 5, connected directly to each other (zero intermediate nodes):

In[1]:=
ResourceFunction["BarbellGraph"][5, 0]
Out[1]=

The same graph, but connected via three intermediate nodes:

In[2]:=
ResourceFunction["BarbellGraph"][5, 3]
Out[2]=

Scope (1) 

A grid of the simplest possible Barbell graphs:

In[3]:=
Grid[Table[
  ResourceFunction["BarbellGraph"][n, m], {n, 2, 8}, {m, 0, 3}]]
Out[3]=

Properties and Relations (3) 

GraphData provides Barbell graphs from size 3 through 20:

In[4]:=
GraphData["Barbell"]
Out[4]=

GraphData does not allow you to specify the number of intermediate nodes:

In[5]:=
Grid[Partition[GraphData /@ GraphData["Barbell"], 4]]
Out[5]=

An example of a BarbellGraph that can not be directly constructed via GraphData:

In[6]:=
ResourceFunction["BarbellGraph"][40, 17]
Out[6]=

Publisher

Arnoud Buzing

Requirements

Wolfram Language 14.0 (January 2024) or above

Version History

  • 1.0.0 – 04 November 2024

License Information