pacman.model.graphs package

Submodules

pacman.model.graphs.abstract_edge module

class pacman.model.graphs.abstract_edge.AbstractEdge[source]

Bases: object

A directed edge in a graph between two vertices.

label

The label of the edge

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
post_vertex

The vertex at the end of the edge

Return type:pacman.model.graphs.abstract_vertex.AbstractVertex
pre_vertex

The vertex at the start of the edge

Return type:pacman.model.graphs.abstract_vertex.AbstractVertex
traffic_type

The traffic type of the edge

Return type:pacman.model.graphs.common.edge_traffic_type.EdgeTrafficType

pacman.model.graphs.abstract_fpga module

class pacman.model.graphs.abstract_fpga.AbstractFPGA[source]

Bases: pacman.model.graphs.abstract_virtual.AbstractVirtual

An Object (most likely a vertex) connected to an FPGA.

Note: It is expected that everything that is an instance of AbstractFPGA is also an instance of AbstractVertex, This is not enforced to avoid diamond inheritance.

fpga_id

The ID of the FPGA to which the vertex is connected.

Return type:int

The link of the FPGA to which the vertex is connected.

Return type:int

pacman.model.graphs.abstract_graph module

class pacman.model.graphs.abstract_graph.AbstractGraph[source]

Bases: object

A graph.

add_constraint(constraint)[source]

Add a constraint to the graph.

Parameters:constraint (AbstractConstraint) – The constraint to add
add_constraints(constraints)[source]

Add a list of constraints to the graph.

Parameters:constraints (list(AbstractConstraint)) – The list of constraints to add
add_edge(edge, outgoing_edge_partition_name)[source]

Add an edge to the graph.

Parameters:
  • edge (pacman.model.graphs.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
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(pacman.model.graphs.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(outgoing_edge_partition)[source]

Add an outgoing edge partition to the graph.

Parameters:outgoing_edge_partition (pacman.model.graphs.AbstractOutgoingEdgePartition) – The outgoing 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 (pacman.model.graphs.AbstractVertex) – The vertex to add

Raises:
add_vertices(vertices)[source]

Add a collection of vertices to the graph.

Parameters:

vertices (iterable(pacman.model.graphs.AbstractVertex)) – The vertices to add

Raises:
constraints

The constraints of the graph.

Return type:iterable(AbstractConstraint)
edges

The edges in the graph

Return type:iterable(pacman.model.graphs.AbstractEdge)
get_edges_ending_at_vertex(vertex)[source]

Get all the edges that end at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edges to get end
Return type:iterable(pacman.model.graphs.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:
Returns:

iterable(pacman.model.graphs.AbstractEdge)

get_edges_starting_at_vertex(vertex)[source]

Get all the edges that start at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edges to get start
Return type:iterable(pacman.model.graphs.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 (pacman.model.graphs.AbstractVertex) – The vertex at the start of the edges in the partition
  • outgoing_edge_partition_name (str) – The name of the edge partition
Return type:

pacman.model.graphs.AbstractOutgoingEdgePartition

get_outgoing_edge_partitions_starting_at_vertex(vertex)[source]

Get all the edge partitions that start at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edge partitions to find starts
Return type:iterable(pacman.model.graphs.AbstractOutgoingEdgePartition)
get_outgoing_partition_for_edge(edge)[source]

gets the outgoing partition this edge is associated with.

Parameters:edge (pacman.model.graphs.AbstractEdge) – the edge to find associated partition
Returns:the outgoing partition
Return type:pacman.model.graphs.AbstractOutgoingEdgePartition
label

The label of the graph.

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
n_outgoing_edge_partitions

The number of outgoing edge partitions in the graph.

Return type:int
n_vertices

The number of vertices in the graph.

Return type:int
outgoing_edge_partitions

The outgoing edge partitions in the graph.

Return type:iterable(pacman.model.graphs.AbstractOutgoingEdgePartition)
vertices

The vertices in the graph.

Return type:iterable(pacman.model.graphs.AbstractVertex)

pacman.model.graphs.abstract_outgoing_edge_partition module

class pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition[source]

Bases: object

A group of edges that start at the same vertex and share the same semantics; used to group edges that can use the same multicast key.

add_constraint(constraint)[source]

Add a constraint to the outgoing edge partition.

Parameters:constraint (AbstractConstraint) – The constraint to add
add_constraints(constraints)[source]

Add a list of constraints to the outgoing edge partition.

Parameters:constraints (iterable(AbstractConstraint)) – The list of constraints to add
add_edge(edge)[source]

Add an edge to the outgoing edge partition.

Parameters:edge (pacman.model.graphs.AbstractEdge) – the edge to add
Raises:pacman.exceptions.PacmanInvalidParameterException – If the starting vertex of the edge does not match that of the edges already in the partition
constraints

The constraints of the outgoing edge partition.

Return type:iterable(AbstractConstraint)
edges

The edges in this outgoing edge partition.

Return type:iterable(pacman.model.graphs.AbstractEdge)
identifier

The identifier of this outgoing edge partition.

Return type:str
label

The label of the outgoing edge partition.

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
n_edges

The number of edges in the outgoing edge partition.

Return type:int
pre_vertex

The vertex at which all edges in this outgoing edge partition start.

Return type:pacman.model.graphs.AbstractVertex
traffic_type

The traffic type of all the edges in this outgoing edge partition.

Return type:pacman.model.graphs.common.EdgeTrafficType
traffic_weight

The weight of the traffic in this outgoing edge partition compared to other partitions.

Return type:int

pacman.model.graphs.abstract_vertex module

class pacman.model.graphs.abstract_vertex.AbstractVertex(label=None, constraints=None)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject

A vertex in a graph.

Parameters:
Raises:

pacman.exceptions.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

Returns the current label to the vertex.

This label could change when the vertex is added to the graph. :return: The label :rtype: str

set_label(label)[source]

Changes the label for a vertex NOT yet ADDED to a graph

Parameters:label – 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

pacman.model.graphs.abstract_virtual module

class pacman.model.graphs.abstract_virtual.AbstractVirtual[source]

Bases: object

An Object (most likely a vertex) which exists outside of the machine, allowing a graph to formally participate in I/O.

Note: It is expected that everything that is an instance of AbstractVirtual is also an instance of AbstractVertex, This is not enforced to avoid diamond inheritance.

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:
  • virtual_chip_x – The x-coordinate of the added chip
  • virtual_chip_y – The y-coordinate of the added chip
virtual_chip_x

The x-coordinate of the virtual chip where this vertex is to be placed.

Return type:int
virtual_chip_y

The y-coordinate of the virtual chip where this vertex is to be placed.

Return type:int

Module contents

class pacman.model.graphs.AbstractEdge[source]

Bases: object

A directed edge in a graph between two vertices.

label

The label of the edge

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
post_vertex

The vertex at the end of the edge

Return type:pacman.model.graphs.abstract_vertex.AbstractVertex
pre_vertex

The vertex at the start of the edge

Return type:pacman.model.graphs.abstract_vertex.AbstractVertex
traffic_type

The traffic type of the edge

Return type:pacman.model.graphs.common.edge_traffic_type.EdgeTrafficType
class pacman.model.graphs.AbstractFPGA[source]

Bases: pacman.model.graphs.abstract_virtual.AbstractVirtual

An Object (most likely a vertex) connected to an FPGA.

Note: It is expected that everything that is an instance of AbstractFPGA is also an instance of AbstractVertex, This is not enforced to avoid diamond inheritance.

fpga_id

The ID of the FPGA to which the vertex is connected.

Return type:int

The link of the FPGA to which the vertex is connected.

Return type:int
class pacman.model.graphs.AbstractGraph[source]

Bases: object

A graph.

add_constraint(constraint)[source]

Add a constraint to the graph.

Parameters:constraint (AbstractConstraint) – The constraint to add
add_constraints(constraints)[source]

Add a list of constraints to the graph.

Parameters:constraints (list(AbstractConstraint)) – The list of constraints to add
add_edge(edge, outgoing_edge_partition_name)[source]

Add an edge to the graph.

Parameters:
  • edge (pacman.model.graphs.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
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(pacman.model.graphs.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(outgoing_edge_partition)[source]

Add an outgoing edge partition to the graph.

Parameters:outgoing_edge_partition (pacman.model.graphs.AbstractOutgoingEdgePartition) – The outgoing 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 (pacman.model.graphs.AbstractVertex) – The vertex to add

Raises:
add_vertices(vertices)[source]

Add a collection of vertices to the graph.

Parameters:

vertices (iterable(pacman.model.graphs.AbstractVertex)) – The vertices to add

Raises:
constraints

The constraints of the graph.

Return type:iterable(AbstractConstraint)
edges

The edges in the graph

Return type:iterable(pacman.model.graphs.AbstractEdge)
get_edges_ending_at_vertex(vertex)[source]

Get all the edges that end at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edges to get end
Return type:iterable(pacman.model.graphs.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:
Returns:

iterable(pacman.model.graphs.AbstractEdge)

get_edges_starting_at_vertex(vertex)[source]

Get all the edges that start at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edges to get start
Return type:iterable(pacman.model.graphs.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 (pacman.model.graphs.AbstractVertex) – The vertex at the start of the edges in the partition
  • outgoing_edge_partition_name (str) – The name of the edge partition
Return type:

pacman.model.graphs.AbstractOutgoingEdgePartition

get_outgoing_edge_partitions_starting_at_vertex(vertex)[source]

Get all the edge partitions that start at the given vertex.

Parameters:vertex (pacman.model.graphs.AbstractVertex) – The vertex at which the edge partitions to find starts
Return type:iterable(pacman.model.graphs.AbstractOutgoingEdgePartition)
get_outgoing_partition_for_edge(edge)[source]

gets the outgoing partition this edge is associated with.

Parameters:edge (pacman.model.graphs.AbstractEdge) – the edge to find associated partition
Returns:the outgoing partition
Return type:pacman.model.graphs.AbstractOutgoingEdgePartition
label

The label of the graph.

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
n_outgoing_edge_partitions

The number of outgoing edge partitions in the graph.

Return type:int
n_vertices

The number of vertices in the graph.

Return type:int
outgoing_edge_partitions

The outgoing edge partitions in the graph.

Return type:iterable(pacman.model.graphs.AbstractOutgoingEdgePartition)
vertices

The vertices in the graph.

Return type:iterable(pacman.model.graphs.AbstractVertex)
class pacman.model.graphs.AbstractOutgoingEdgePartition[source]

Bases: object

A group of edges that start at the same vertex and share the same semantics; used to group edges that can use the same multicast key.

add_constraint(constraint)[source]

Add a constraint to the outgoing edge partition.

Parameters:constraint (AbstractConstraint) – The constraint to add
add_constraints(constraints)[source]

Add a list of constraints to the outgoing edge partition.

Parameters:constraints (iterable(AbstractConstraint)) – The list of constraints to add
add_edge(edge)[source]

Add an edge to the outgoing edge partition.

Parameters:edge (pacman.model.graphs.AbstractEdge) – the edge to add
Raises:pacman.exceptions.PacmanInvalidParameterException – If the starting vertex of the edge does not match that of the edges already in the partition
constraints

The constraints of the outgoing edge partition.

Return type:iterable(AbstractConstraint)
edges

The edges in this outgoing edge partition.

Return type:iterable(pacman.model.graphs.AbstractEdge)
identifier

The identifier of this outgoing edge partition.

Return type:str
label

The label of the outgoing edge partition.

Returns:The label
Return type:str
Raises:None – Raises no known exceptions
n_edges

The number of edges in the outgoing edge partition.

Return type:int
pre_vertex

The vertex at which all edges in this outgoing edge partition start.

Return type:pacman.model.graphs.AbstractVertex
traffic_type

The traffic type of all the edges in this outgoing edge partition.

Return type:pacman.model.graphs.common.EdgeTrafficType
traffic_weight

The weight of the traffic in this outgoing edge partition compared to other partitions.

Return type:int

Bases: pacman.model.graphs.abstract_virtual.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.

The SpiNNaker Link that the vertex is connected to.

class pacman.model.graphs.AbstractVertex(label=None, constraints=None)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject

A vertex in a graph.

Parameters:
Raises:

pacman.exceptions.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

Returns the current label to the vertex.

This label could change when the vertex is added to the graph. :return: The label :rtype: str

set_label(label)[source]

Changes the label for a vertex NOT yet ADDED to a graph

Parameters:label – 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[source]

Bases: object

An Object (most likely a vertex) which exists outside of the machine, allowing a graph to formally participate in I/O.

Note: It is expected that everything that is an instance of AbstractVirtual is also an instance of AbstractVertex, This is not enforced to avoid diamond inheritance.

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:
  • virtual_chip_x – The x-coordinate of the added chip
  • virtual_chip_y – The y-coordinate of the added chip
virtual_chip_x

The x-coordinate of the virtual chip where this vertex is to be placed.

Return type:int
virtual_chip_y

The y-coordinate of the virtual chip where this vertex is to be placed.

Return type:int