Example graphs#

The path graph \(P_n\)#

A path graph is a graph whose \(n\) vertices can be listed in the order \(0, 1, \ldots , n-1\) such that the edges are \((i, i+1)\) for \(i = 0, 1 \ldots , n-2\). For example, the undirected graphs \(P_3\) and \(P_6\) are shown below.

Hide code cell source

for n in [3,6]:
  G=graphs.PathGraph(n)
  G.show(figsize=4,graph_border=True,title=f'P{n}')
_images/d796dd1a508e42c8d2c624c81f182236d33bf84cfb0dec29f049d6bcdc8616bd.png _images/704dd2b4a5e18b8585828421c4eca9cbd1fd90834e51c6d93faf4c67855ad983.png

The cycle graph \(C_n\)#

The cycle graph \(C_n\) is a graph whose $n$ vertices can be listed in the order \(0, 1, \ldots , n\) such that the edges are \((i, i+1)\) for \(i = 0, 1, \ldots , n-2\), and also \((0,n-1)\). For example, \(C_3\), \(C_5\), and \(C_{12}\) are

Hide code cell source

for n in [3,5,12]:
    graphs.CycleGraph(n).show(figsize=3,title='C%s:' %(n))
_images/9e1096e846b054408f2d3af47c47e00f71a08b7b56549ce799c993a940d832af.png _images/ba2ab72d3522308e31ac8587697f7436081440f3702910b55781b06368b749ca.png _images/9db7997b49acc26461e1d544af775521e3e495b974f66e2525721cc99e97bd91.png

The complete graph \(K_n\)#

The complete graph \(K_n\) is a graph with \(n\) vertices and \(|E(K_n)|=\binom{n}{2}\) edges.
For example, \(K_2\), \(K_4\), and \(K_7\) are

Hide code cell source

for n in [2,4,7]:
    graphs.CompleteGraph(n).show(figsize=3,title='K%s:' %(n))
_images/83dbb24de3f3609657d5ef9b9e3efd763282c10f73890aa4ad634dbc10b0cbbc.png _images/c90201887e8b17ea28cbc0605eef5d832a7cc84d811969b717832551ea7ebf98.png _images/51f7fdb689e1d6080ca8b68be9947aeb9650215ab24902481ef4978df4ad7a07.png

The hypercube graph \(Q_n\)#

The hypercube graph \(Q_n\) has \(|V(Q_n)|=2^n\) vertices and \(|E(Q_n)|=2^{n-1}n\) edges. For example, \(Q_2\) and \(Q_5\) are

Hide code cell source

for n in [2,5,9]:
    if n>3:
        graphs.CubeGraph(n).show(figsize=3,vertex_size=20,vertex_labels=false,title='Q%s:' %(n))
    else:
        graphs.CubeGraph(n).show(figsize=3,title='Q%s:' %(n))
_images/ca9dec13d1875d43a2eae336701817b650ac7b794b86c1c5251a6079433e990b.png _images/a4544f7ec70ca3a2e3bd9838bfd92048ccf703ce9539f3bdeb6e80a56718862b.png _images/3b9611d8523fa9bd765d1268104a87456c826ba7a5351efc28137f3a61452d94.png

Here is a 3D image of \(Q_4\):

Hide code cell source

n=4
graphs.CubeGraph(n).show3d(title='Q%s:' %(n))

Here is a 3D image of \(Q_3\) and \(Q_4\):

Hide code cell source

for n in [3,4]:
    graphs.CubeGraph(n).show3d(title='Q%s:' %(n))