pacman.model.graphs.impl package

Submodules

pacman.model.graphs.impl.graph module

class pacman.model.graphs.impl.graph.Graph(allowed_vertex_types, allowed_edge_types, allowed_partition_types, label)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject, pacman.model.graphs.abstract_graph.AbstractGraph

A graph implementation that specifies the allowed types of the vertices and edges

Parameters:
  • allowed_vertex_types – A single or tuple of types of vertex to be allowed in the graph
  • allowed_edge_types – A single or tuple of types of edges to be allowed in the graph
  • allowed_partition_types – A single or tuple of types of partitions to be allowed in the graph
  • label – The label on the graph, or None
add_edge(edge, outgoing_edge_partition_name)[source]

Add an edge to the graph

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

Add an outgoing edge partition to the graph

Parameters:outgoing_edge_partition (pacman.model.graphs.abstract_outgoing_edge_partition.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.abstract_vertex.AbstractVertex) – The vertex to add
Raises:PacmanInvalidParameterException – If the vertex is not of a valid type
edges

The edges in the graph

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

Get all the edges that end at the given vertex

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

get_edges_starting_at_vertex(vertex)[source]

Get all the edges that start at the given vertex

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

pacman.model.graphs.abstract_outgoing_edge_partition.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.abstract_vertex.AbstractVertex) – The vertex at which the edge partitions to find starts
Return type:iterable of pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition
get_outgoing_edge_partitions_with_traffic_type(traffic_type)[source]

Get the outgoing edge partitions with a given traffic type

Parameters:traffic_type (pacman.model.graphs.common.edge_traffic_type.EdgeTrafficType) – The traffic type to look for
label

The label of the item

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 of pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition
vertices

The vertices in the graph

Return type:iterable of pacman.model.graphs.abstract_vertex.AbstractVertex

pacman.model.graphs.impl.outgoing_edge_partition module

class pacman.model.graphs.impl.outgoing_edge_partition.OutgoingEdgePartition(identifier, allowed_edge_types, constraints=None, label=None, traffic_weight=1)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject, pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition

A collection of edges which start at a single vertex which have the
same semantics and so can share a single key
Parameters:
  • identifier – The identifier of the partition
  • allowed_edge_types – The types of edges allowed
  • constraints – Any initial constraints
  • label – An optional label of the partition
  • traffic_weight – The weight of traffic going down this partition
add_edge(edge)[source]

Add an edge to the partition

Parameters:edge (pacman.model.graphs.abstract_edge.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
edges

The edges in this outgoing edge partition

Return type:iterable of pacman.model.graphs.abstract_edge.AbstractEdge
identifier

The identifier of this outgoing edge partition

Return type:str
label

The label of the item

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

The number of edges in the partition

Return type:int
pre_vertex

The vertex at which all edges in this partition start

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

The traffic type of all the edges in this partition

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

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

Return type:int

Module contents

class pacman.model.graphs.impl.Graph(allowed_vertex_types, allowed_edge_types, allowed_partition_types, label)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject, pacman.model.graphs.abstract_graph.AbstractGraph

A graph implementation that specifies the allowed types of the vertices and edges

Parameters:
  • allowed_vertex_types – A single or tuple of types of vertex to be allowed in the graph
  • allowed_edge_types – A single or tuple of types of edges to be allowed in the graph
  • allowed_partition_types – A single or tuple of types of partitions to be allowed in the graph
  • label – The label on the graph, or None
add_edge(edge, outgoing_edge_partition_name)[source]

Add an edge to the graph

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

Add an outgoing edge partition to the graph

Parameters:outgoing_edge_partition (pacman.model.graphs.abstract_outgoing_edge_partition.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.abstract_vertex.AbstractVertex) – The vertex to add
Raises:PacmanInvalidParameterException – If the vertex is not of a valid type
edges

The edges in the graph

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

Get all the edges that end at the given vertex

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

get_edges_starting_at_vertex(vertex)[source]

Get all the edges that start at the given vertex

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

pacman.model.graphs.abstract_outgoing_edge_partition.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.abstract_vertex.AbstractVertex) – The vertex at which the edge partitions to find starts
Return type:iterable of pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition
get_outgoing_edge_partitions_with_traffic_type(traffic_type)[source]

Get the outgoing edge partitions with a given traffic type

Parameters:traffic_type (pacman.model.graphs.common.edge_traffic_type.EdgeTrafficType) – The traffic type to look for
label

The label of the item

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 of pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition
vertices

The vertices in the graph

Return type:iterable of pacman.model.graphs.abstract_vertex.AbstractVertex
class pacman.model.graphs.impl.OutgoingEdgePartition(identifier, allowed_edge_types, constraints=None, label=None, traffic_weight=1)[source]

Bases: pacman.model.graphs.common.constrained_object.ConstrainedObject, pacman.model.graphs.abstract_outgoing_edge_partition.AbstractOutgoingEdgePartition

A collection of edges which start at a single vertex which have the
same semantics and so can share a single key
Parameters:
  • identifier – The identifier of the partition
  • allowed_edge_types – The types of edges allowed
  • constraints – Any initial constraints
  • label – An optional label of the partition
  • traffic_weight – The weight of traffic going down this partition
add_edge(edge)[source]

Add an edge to the partition

Parameters:edge (pacman.model.graphs.abstract_edge.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
edges

The edges in this outgoing edge partition

Return type:iterable of pacman.model.graphs.abstract_edge.AbstractEdge
identifier

The identifier of this outgoing edge partition

Return type:str
label

The label of the item

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

The number of edges in the partition

Return type:int
pre_vertex

The vertex at which all edges in this partition start

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

The traffic type of all the edges in this partition

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

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

Return type:int