sgtl.graph.path_graph#
- sgtl.graph.path_graph(number_of_vertices: int) Graph #
Construct the unweighted path graph on \(n\) vertices.
- Parameters:
number_of_vertices – The number of vertices in the graph
- Returns:
The path 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.path_graph(5) >>> graph.adjacency_matrix().toarray() array([[0., 1., 0., 0., 0.], [1., 0., 1., 0., 0.], [0., 1., 0., 1., 0.], [0., 0., 1., 0., 1.], [0., 0., 0., 1., 0.]])