topology¶
import qrules.topology
All modules related to topology building.
Responsible for building all possible topologies bases on basic user input:
number of initial state particles
number of final state particles
The main interface is the StateTransitionGraph
.
- class Edge(originating_node_id: Optional[int] = None, ending_node_id: Optional[int] = None)[source]¶
Bases:
object
Struct-like definition of an edge, used in
Topology
.
- class FrozenDict(mapping: Optional[Mapping] = None)[source]¶
Bases:
Generic
[qrules.topology.KeyType
,qrules.topology.ValueType
],collections.abc.Hashable
,collections.abc.Mapping
- values() ValuesView [source]¶
- class InteractionNode(number_of_ingoing_edges: int, number_of_outgoing_edges: int)[source]¶
Bases:
object
Helper class for the
SimpleStateTransitionTopologyBuilder
.
- KeyType¶
Type the keys of the
Mapping
, seeKeysView
.alias of TypeVar(‘KeyType’, bound=
qrules.topology.Comparable
)
- class SimpleStateTransitionTopologyBuilder(interaction_node_set: Iterable[InteractionNode])[source]¶
Bases:
object
Simple topology builder.
Recursively tries to add the interaction nodes to available open end edges/lines in all combinations until the number of open end lines matches the final state lines.
- class StateTransitionGraph(topology: Topology, node_props: Mapping[int, InteractionProperties], edge_props: Mapping[int, EdgeType])[source]¶
Bases:
Generic
[qrules.topology.EdgeType
]Graph class that resembles a frozen
Topology
with properties.This class should contain the full information of a state transition from a initial state to a final state. This information can be attached to the nodes and edges via properties. In case not all information is provided, error can be raised on property retrieval.
- compare(other: StateTransitionGraph, edge_comparator: Optional[Callable[[EdgeType, EdgeType], bool]] = None, node_comparator: Optional[Callable[[InteractionProperties, InteractionProperties], bool]] = None) bool [source]¶
- evolve(node_props: Optional[Dict[int, InteractionProperties]] = None, edge_props: Optional[Dict[int, EdgeType]] = None) StateTransitionGraph[EdgeType] [source]¶
Changes the node and edge properties of a graph instance.
Since a
StateTransitionGraph
is frozen (cannot be modified), the evolve function will also create a shallow copy the properties.
- get_node_props(node_id: int) InteractionProperties [source]¶
- class Topology(nodes: Iterable[int], edges)[source]¶
Bases:
object
Directed Feynman-like graph without edge or node properties.
Forms the underlying topology of
StateTransitionGraph
. The graphs are directed, meaning the edges are ingoing and outgoing to specific nodes (since feynman graphs also have a time axis). Note that aTopology
is not strictly speaking a graph from graph theory, because it allows open edges, like a Feynman-diagram.- edges: FrozenDict[int, Edge]¶
- is_isomorphic(other: Topology) bool [source]¶
Check if two graphs are isomorphic.
- Returns
True if the two graphs have a one-to-one mapping of the node IDs and edge IDs.
- Return type
- organize_edge_ids() Topology [source]¶
Create a new topology with edge IDs in range
[-m, n+i]
.where
m
is the number ofincoming_edge_ids
,n
is the number ofoutgoing_edge_ids
, andi
is the number ofintermediate_edge_ids
.In other words, relabel the edges so that:
incoming_edge_ids
lies in the range[-1, -2, ...]
outgoing_edge_ids
lies in the range[0, 1, ..., n]
intermediate_edge_ids
lies in the range[n+1, n+2, ...]
- ValueType¶
Type the value of the
Mapping
, seeValuesView
.alias of TypeVar(‘ValueType’)