List of topologies#
Topologies exposed from C++#
- class pygmo.unconnected#
Unconnected topology.
This user-defined topology (UDT) represents an unconnected graph. This is the default UDT used by
pygmo.topology
.See also the docs of the C++ class
pagmo::unconnected
.
- class pygmo.ring(n=0, w=1.)#
Ring topology.
This user-defined topology (UDT) represents a bidirectional ring (that is, a ring in which each node connects to both the previous and the following nodes).
See also the docs of the C++ class
pagmo::ring
.- Parameters
- Raises
TypeError – if n is negative or too large
ValueError – if w is not in the \(\left[0, 1\right]\) range
- add_edge(i, j, w=1.)#
Add a new edge.
This method will add a new edge of weight w connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, i and j are already adjacent, or if w is not in the \(\left[0, 1\right]\) range
- add_vertex()#
Add a vertex.
This method will add a new vertex to the topology.
The newly-added vertex will be disjoint from any other vertex in the topology (i.e., there are no connections to/from the new vertex).
- are_adjacent(i, j)#
Check if two vertices are adjacent.
Two vertices i and j are adjacent if there is a directed edge connecting i to j.
- get_edge_weight(i, j)#
New in version 2.15.
Fetch the weight of the edge connecting i to j.
- Parameters
- Returns
the weight of the edge connecting i to j
- Return type
- Raises
TypeError – if i or j are negative or too large
ValueError – if either i or j are not smaller than the number of vertices, or i and j are not adjacent
- remove_edge(i, j)#
Remove an existing edge.
This method will remove the edge connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, or i and j are not adjacent
- set_all_weights(w)#
This method will set the weights of all edges in the topology to w.
- Parameters
w (
float
) – the edges’ weight- Raises
ValueError – if w is not in the \(\left[0, 1\right]\) range
- set_weight(i, j, w)#
Set the weight of an edge.
This method will set to w the weight of the edge connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, i and j are not adjacent, or if w is not in the \(\left[0, 1\right]\) range
- class pygmo.fully_connected(n=0, w=1.)#
Fully connected topology.
This user-defined topology (UDT) represents a complete graph (that is, a topology in which all vertices connect to all other vertices). The edge weight is configurable at construction, and it will be the same for all the edges in the topology.
See also the docs of the C++ class
pagmo::fully_connected
.- Parameters
- Raises
TypeError – if n is negative or too large
ValueError – if w is not in the \(\left[0, 1\right]\) range
- class pygmo.free_form(t=None)#
Free-form topology.
This user-defined topology (UDT) represents a graph in which vertices and edges can be manipulated freely. Instances of this class can be constructed from either:
Construction from
None
will initialise a topology without vertices or edges.Construction from a
networkx.DiGraph
will initialise a topology whose vertices and edges are described by the input graph. All the edges of the input graph must have afloat
attribute calledweight
whose value is in the \(\left[0 , 1\right]\) range.When t is a
topology
or a UDT, the constructor will attempt to fetch the NetworkX representation of the input object via thepygmo.topology.to_networkx()
method, and will then proceed in the same manner explained in the previous paragraph.See also the docs of the C++ class
pagmo::free_form
.- Parameters
t – the object that will be used for construction
- Raises
ValueError – if the edges of the input
networkx.DiGraph
do not all have aweight
attribute, or if any edge weight is outside the \(\left[ 0, 1 \right]\) rangeunspecified – any exception thrown by
pygmo.topology.to_networkx()
, or by the construction of atopology
from a UDT
- add_edge(i, j, w=1.)#
Add a new edge.
This method will add a new edge of weight w connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, i and j are already adjacent, or if w is not in the \(\left[0, 1\right]\) range
- add_vertex()#
Add a vertex.
This method will add a new vertex to the topology.
The newly-added vertex will be disjoint from any other vertex in the topology (i.e., there are no connections to/from the new vertex).
- are_adjacent(i, j)#
Check if two vertices are adjacent.
Two vertices i and j are adjacent if there is a directed edge connecting i to j.
- get_edge_weight(i, j)#
New in version 2.15.
Fetch the weight of the edge connecting i to j.
- Parameters
- Returns
the weight of the edge connecting i to j
- Return type
- Raises
TypeError – if i or j are negative or too large
ValueError – if either i or j are not smaller than the number of vertices, or i and j are not adjacent
- remove_edge(i, j)#
Remove an existing edge.
This method will remove the edge connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, or i and j are not adjacent
- set_all_weights(w)#
This method will set the weights of all edges in the topology to w.
- Parameters
w (
float
) – the edges’ weight- Raises
ValueError – if w is not in the \(\left[0, 1\right]\) range
- set_weight(i, j, w)#
Set the weight of an edge.
This method will set to w the weight of the edge connecting i to j.
- Parameters
- Raises
TypeError – if i or j are negative or too large
ValueError – if i or j are not smaller than the number of vertices, i and j are not adjacent, or if w is not in the \(\left[0, 1\right]\) range