sgtl.graph.cycle_graph

sgtl.graph.cycle_graph(number_of_vertices: int) sgtl.graph.Graph

Construct the unweighted cycle graph on \(n\) vertices.

Parameters

number_of_vertices – The number of vertices in the graph

Returns

The cycle graph on \(n\) vertices, as a Graph object.

Raises

ValueError – if the number of vertices is not a positive integer.

Example
>>> import sgtl.graph
>>> graph = sgtl.graph.cycle_graph(5)
>>> graph.adjacency_matrix().toarray()
array([[0., 1., 0., 0., 1.],
       [1., 0., 1., 0., 0.],
       [0., 1., 0., 1., 0.],
       [0., 0., 1., 0., 1.],
       [1., 0., 0., 1., 0.]])