pacman.model.graphs package¶
Subpackages¶
Module contents¶

class
pacman.model.graphs.
AbstractEdge
¶ Bases:
object
A directed edge in a graph between two vertices.

post_vertex
¶ The vertex at the end of the edge
Return type: AbstractVertex

pre_vertex
¶ The vertex at the start of the edge
Return type: AbstractVertex


class
pacman.model.graphs.
AbstractEdgePartition
(identifier, allowed_edge_types, constraints, label, traffic_weight, class_name)¶ Bases:
pacman.model.graphs.common.constrained_object.ConstrainedObject
A collection of edges which start at a single vertex which have the same semantics and so can share a single key or block of SDRAM (depending on edge type).
Parameters:  identifier (str) – The identifier of the partition
 allowed_edge_types (type or tuple(type, ..)) – The types of edges allowed
 constraints (iterable(AbstractConstraint)) – Any initial constraints
 label (str) – An optional label of the partition
 traffic_weight (int) – The weight of traffic going down this partition

add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters:  edge (AbstractEdge) – the edge to add
 graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition

clone_without_edges
()[source]¶ Make a copy of this edge partition without any of the edges in it
This follows the design pattern that only the graph adds edges to partitions already added to the graph
Returns: The copied edge partition but excluding edges

edges
¶ The edges in this edge partition.
Note
The order in which the edges are added is preserved for when they are requested later. If not, please talk to the software team.
Return type: iterable(AbstractEdge)

pre_vertices
¶ Provides the vertices associated with this partition
Note
Most edge partitions will be
AbstractSingleSourcePartition
and therefore provide thepre_vertex
method.Return type: iter(AbstractVertex)

class
pacman.model.graphs.
AbstractFPGA
¶ Bases:
pacman.model.graphs.AbstractVirtual
A vertex connected to an FPGA.
Note
Everything that is an instance of AbstractFPGA is also an instance of
AbstractVertex
.

class
pacman.model.graphs.
AbstractMultiplePartition
(pre_vertices, identifier, allowed_edge_types, constraints, label, traffic_weight, class_name)¶ Bases:
pacman.model.graphs.AbstractEdgePartition
An edge partition that has multiple source vertices.

add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters:  edge (AbstractEdge) – the edge to add
 graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition

pre_vertices
¶ Provides the vertices associated with this partition
Note
Most edge partitions will be
AbstractSingleSourcePartition
and therefore provide thepre_vertex
method.Return type: iter(AbstractVertex)


class
pacman.model.graphs.
AbstractSingleSourcePartition
(pre_vertex, identifier, allowed_edge_types, constraints, label, traffic_weight, class_name)¶ Bases:
pacman.model.graphs.AbstractEdgePartition
An edge partition that has a single source vertex.

add_edge
(edge, graph_code)[source]¶ Add an edge to the edge partition.
Note
This method should only be called by the
add_edge
method of the graph that owns the partition. Calling it from anywhere else, even with the correct graph_code, will lead to unsupported inconsistency.Parameters:  edge (AbstractEdge) – the edge to add
 graph_code (int) – A code to check the correct graph is calling this method
Raises: PacmanInvalidParameterException – If the edge does not belong in this edge partition

pre_vertex
¶ The vertex at which all edges in this outgoing edge partition start.
Return type: AbstractVertex

pre_vertices
¶ Provides the vertices associated with this partition
Note
Most edge partitions will be
AbstractSingleSourcePartition
and therefore provide thepre_vertex
method.Return type: iter(AbstractVertex)


class
pacman.model.graphs.
AbstractSpiNNakerLink
¶ Bases:
pacman.model.graphs.AbstractVirtual
An Object (most likely a vertex) connected to a SpiNNaker Link.
Note
It is expected that everything that is an instance of AbstractSpiNNakerLink is also an instance of
AbstractVertex
. This is not enforced to avoid diamond inheritance.

class
pacman.model.graphs.
AbstractSupportsSDRAMEdges
¶ Bases:
object
Marks a machine vertex that can have SDRAM edges attached to it.

class
pacman.model.graphs.
AbstractVertex
(label=None, constraints=None)¶ Bases:
pacman.model.graphs.common.constrained_object.ConstrainedObject
A vertex in a graph.
Parameters:  label (str) – The optional name of the vertex
 constraints (iterable(AbstractConstraint)) – The optional initial constraints of the vertex
Raises: PacmanInvalidParameterException – If one of the constraints is not valid

addedToGraph
()[source]¶ Records that the vertex has been added to a graph
Raises: PacmanConfigurationException – If there is an attempt to add the same vertex more than once

label
¶ The current label to the vertex.
This label could change when the vertex is added to the graph.
Return type: str

set_label
(label)[source]¶ Changes the label for a vertex not yet added to a graph.
Parameters: label (str) – new value for the label Raises: PacmanConfigurationException – If there is an attempt to change the label once the vertex has been added to a graph

class
pacman.model.graphs.
AbstractVirtual
¶ Bases:
object
A vertex which exists outside of the machine, allowing a graph to formally participate in I/O.
Note
Everything that is an instance of
AbstractVirtual
is also an instance ofAbstractVertex
.
board_address
¶ The IP address of the board to which the device is connected, or
None
for the boot board.Return type: str

set_virtual_chip_coordinates
(virtual_chip_x, virtual_chip_y)[source]¶ Set the details of the virtual chip that has been added to the machine for this vertex.
Parameters:


class
pacman.model.graphs.
Graph
(allowed_vertex_types, allowed_edge_types, label)¶ Bases:
pacman.model.graphs.common.constrained_object.ConstrainedObject
A graph that specifies the allowed types of the vertices and edges.
Parameters: 
add_edge
(edge, outgoing_edge_partition_name)[source]¶ Add an edge to the graph and its partition
If required and possible will create a new partition in the graph
Returns the partition the edge was added to
Parameters:  edge (AbstractEdge) – The edge to add
 outgoing_edge_partition_name (str) – The name of the edge partition to add the edge to; each edge partition is the partition of edges that start at the same vertex
Return type: Raises: PacmanInvalidParameterException – If the edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one

add_edges
(edges, outgoing_edge_partition_name)[source]¶ Add a collection of edges to the graph.
Parameters:  edges (iterable(AbstractEdge)) – The edges to add
 outgoing_edge_partition_name (str) – The name of the edge partition to add the edges to; each edge partition is the partition of edges that start at the same vertex
Raises: PacmanInvalidParameterException – If any edge is not of a valid type or if edges have already been added to this partition that start at a different vertex to this one

add_outgoing_edge_partition
(edge_partition)[source]¶ Add an edge partition to the graph.
Will also add any edges already in the partition as well
Parameters: edge_partition (AbstractEdgePartition) – The edge partition to add Raises: PacmanAlreadyExistsException – If a partition already exists with the same pre_vertex and identifier

add_vertex
(vertex)[source]¶ Add a vertex to the graph.
Parameters: vertex (AbstractVertex) – The vertex to add
Raises:  PacmanInvalidParameterException – If the vertex is not of a valid type
 PacmanConfigurationException – If there is an attempt to add the same vertex more than once

add_vertices
(vertices)[source]¶ Add a collection of vertices to the graph.
Parameters: vertices (iterable(AbstractVertex)) – The vertices to add
Raises:  PacmanInvalidParameterException – If any vertex is not of a valid type
 PacmanConfigurationException – If there is an attempt to add the same vertex more than once

edges
¶ The edges in the graph
Return type: iterable(AbstractEdge)

get_edges_ending_at_vertex
(vertex)[source]¶ Get all the edges that end at the given vertex.
Parameters: vertex (AbstractVertex) – The vertex at which the edges to get end Return type: iterable(AbstractEdge)

get_edges_ending_at_vertex_with_partition_name
(vertex, partition_name)[source]¶ Get all the edges that end at the given vertex, and reside in the correct partition ID.
Parameters:  vertex (AbstractVertex) – The vertex at which the edges to get end
 partition_name (str) – the label for the partition
Returns: iterable(AbstractEdge)

get_edges_starting_at_vertex
(vertex)[source]¶ Get all the edges that start at the given vertex.
Parameters: vertex (AbstractVertex) – The vertex at which the edges to get start Return type: iterable(AbstractEdge)

get_outgoing_edge_partition_starting_at_vertex
(vertex, outgoing_edge_partition_name)[source]¶  Get the given outgoing edge partition that starts at the
 given vertex, or None if no such edge partition exists.
Parameters:  vertex (AbstractVertex) – The vertex at the start of the edges in the partition
 outgoing_edge_partition_name (str) – The name of the edge partition
Returns: the named edge partition, or None if no such partition exists
Return type:

get_outgoing_edge_partitions_starting_at_vertex
(vertex)[source]¶ Get all the edge partitions that start at the given vertex.
Parameters: vertex (AbstractVertex) – The vertex at which the edge partitions to find starts Return type: iterable(AbstractEdgePartition)

get_outgoing_partition_for_edge
(edge)[source]¶ Gets the partition this edge is associated with.
Parameters: edge (AbstractEdge) – the edge to find associated partition Return type: AbstractEdgePartition

new_edge_partition
(name, edge)[source]¶ How we create a new
AbstractSingleSourcePartition
in the first place. Uses the first/only element in the allowed partition types argument to the graph’s constructor.Called from
add_edge()
. Can be overridden if different arguments should be passed.Parameters:  name (str) – The identifier of the partition
 edge (AbstractEdge) – An edge for the partition
Returns: the new edge partition
Return type:

outgoing_edge_partitions
¶ The edge partitions in the graph.
Return type: iterable(AbstractEdgePartition)

vertices
¶ The vertices in the graph.
Return type: iterable(AbstractVertex)
