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:
- Direct matrix types such as:
List of lists.
networkx.Graph
:The adjacency matrix is automatically extracted from the specified networkx graph.
- 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 originaladj_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 withcopy=True
. Alternatively, the original matrix can be retrieved anytime by callingadjacency_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.
Methods
Return the adjacency matrix representation of the graph.
adjacent
(u, v)Return True if vertex
u
is adjacent tov
.degree
(vertex)Return the degree of the given vertex.
Return False.
Return the graph's Laplacian matrix.
neighbors
(vertex)Return all neighbors of the given vertex.
number_of_edges
([u, v])Return number of edges.
Return the number of loops in the graph.
Return the total number of vertices in the graph.
vertex_number
(vertex)Return the numerical label of a vertex based on its representation.