Graphs#
Classes#
There are three classes of graph.
Constructs an arbitrary graph. |
|
Construct an arbitrary multigraph. |
|
Construct an arbitrary weighted graph. |
hiperwalk.Multigraph
is used as input for the
hiperwalk.Coined
quantum walk model.
hiperwalk.WeightedGraph
is used as input for the
hiperwalk.ContinuousTime
quantum walk model.
hiperwalk.Graph
is used as input for
both quantum walk models.
Graph Constructors#
The graph constructors [1] return an instance of commonly used graphs.
The graph constructors are used to change the default behavior of specific graphs. For instance, the order of the neighbors changes depending on the graph.
Every constructor has the following template:
>>> GraphConstructor(args, multiedges=None, weights=None)
where multiedges
and weights
are optional arguments
whose default value is None
.
Every graph constructor returns an instance of
hiperwalk.Graph
ifmultiedges is None
andweights is None
.hiperwalk.Multigraph
ifmultiedges is not None
andweights is None
.hiperwalk.WeightedGraph
ifmultiedges is None
andweights is not None
.
Both multiedges
and weights
are expected to be
instances of dict
or scipy.sparse.csr_array
.
If they are an instance of
dict
in the{(u, v): value}
format.multiedges[(u, v)]
is the number of edges incident to both verticesu
andv
.weights[(u, v)]
is the weight of the edge incident to both verticesu
andv
.
If an edge exists in the graph but it is not listed in the
dict
keys, its value defaults to 1. Attempting to remove an edge by assigning its value to 0 (e.g.weights[(u, v)] = 0
) or attempting to add an edge by assigning a value to it (e.g.weights[(-1, -1) = 10])
raises a a ValueError exception.If they are an instance of
scipy.sparse.csr_array
,multiedges[u, v]
is the number of edges incident to both verticesu
andv
.weights[u, v]
is the weight of the edge incident to both verticesu
andv
.
In this case, all valid edges must have been assigned a value different from 0. When explicitly specifying the adjacency matrix, the
copy
changes the method’s behavior.If
copy = False
(default), a pointer to the adjacency matrix is stored.If
copy = True
, a hard copy of the adjacency matrix is stored.
If multiedges is not None
and weights is not None
,
a ValueError exception
is raised.
List of Graph Constructors#
The following is the list of all available graph constructors.