hiperwalk.Multigraph#

class hiperwalk.Multigraph(adj_matrix, copy=False)[source]#

Construct an arbitrary multigraph.

This class facilitates the creation of a multigraph, in which multiple edges between the same pair of vertices are allowed. The graph’s structure is determined by a Hermitian adjacency matrix, the entries of which are non-negative integers that represent the number of multiple edges between vertices. The multigraph also supports loops, which are considered arcs.

Parameters:
adj_matrixvarious types accepted

The adjacency matrix of the graph, which must be a Hermitian matrix with non-negative integer entries. Acceptable input types include:

copybool, default=False

Specifies whether to store a hard copy of adj_matrix:

  • If True, a deep copy of the adjacency matrix is created and stored.

  • If False, a reference to the original adj_matrix is stored.

Raises:
TypeError

If adj_matrix is not a square matrix.

Notes

The adj_matrix.data attribute may be modified for more efficient manipulation. If the original matrix data is required, it is recommended to initialize the constructor with copy=True. Alternatively, the original matrix can be retrieved anytime by calling adjacency_matrix() after the multigraph has been created.

When defining an instance of the Coined class on a multigraph, the number of multiple edges impacts the dimension of the coin.

When defining an instance of the ContinuousTime class on a multigraph, the number of multiple edges is treated as an edge weight.

__init__(adj_matrix, copy=False)[source]#

Methods

adjacency_matrix()

Return the adjacency matrix representation of the graph.

adjacent(u, v)

Return True if vertex u is adjacent to v.

degree(vertex)

Return the degree of the given vertex.

is_simple()

Return False.

laplacian_matrix()

Return the graph's Laplacian matrix.

neighbors(vertex)

Return all neighbors of the given vertex.

number_of_edges([u, v])

Return number of edges.

number_of_loops()

Return the number of loops in the graph.

number_of_vertices()

Return the total number of vertices in the graph.

vertex_number(vertex)

Return the numerical label of a vertex based on its representation.