Deprecated since version 0.7.3: Use QRules and AmpForm instead

import expertsystem.reaction.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=None, ending_node_id=None)[source]

Bases: object

Struct-like definition of an edge, used in Topology.


Method generated by attrs for class Edge.

ending_node_id: Optional[int]
originating_node_id: Optional[int]

A TypeVar representing the type of edge properties.

alias of TypeVar(‘EdgeType’)

class FrozenDict(mapping: Optional[Mapping] = None)[source]

Bases: Generic[expertsystem.reaction.topology.KeyType, expertsystem.reaction.topology.ValueType],,

__getitem__(key: KeyType)ValueType[source]
class InteractionNode(number_of_ingoing_edges: int, number_of_outgoing_edges: int)[source]

Bases: object

Helper class for the SimpleStateTransitionTopologyBuilder.


Method generated by attrs for class InteractionNode.

number_of_ingoing_edges: int
number_of_outgoing_edges: int

Data type of the keys in a dict, see typing.KeysView.

alias of TypeVar(‘KeyType’)

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.

build(number_of_initial_edges: int, number_of_final_edges: int)Tuple[Topology, ][source]
class StateTransitionGraph(topology: Topology, node_props: Mapping[int, InteractionProperties], edge_props: Mapping[int, EdgeType])[source]

Bases: Generic[expertsystem.reaction.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.

__eq__(other: object)bool[source]

Check if two StateTransitionGraph instances are identical.

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_edge_props(edge_id: int)EdgeType[source]
get_node_props(node_id: int)InteractionProperties[source]
swap_edges(edge_id1: int, edge_id2: int)None[source]
class Topology(nodes, 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 a Topology is not strictly speaking a graph from graph theory, because it allows open edges, like a Feynman-diagram.


Method generated by attrs for class Topology.

edges: FrozenDict[int, Edge]
get_edge_ids_ingoing_to_node(node_id: int)Set[int][source]
get_edge_ids_outgoing_from_node(node_id: int)Set[int][source]
get_originating_final_state_edge_ids(node_id: int)Set[int][source]
get_originating_initial_state_edge_ids(node_id: int)Set[int][source]
incoming_edge_ids: FrozenSet[int]
intermediate_edge_ids: FrozenSet[int]
is_isomorphic(other: Topology)bool[source]

Check if two graphs are isomorphic.


True if the two graphs have a one-to-one mapping of the node IDs and edge IDs.

Return type


nodes: FrozenSet[int]

Create a new topology with edge IDs in range [-m, n+i].

where m is the number of incoming_edge_ids, n is the number of outgoing_edge_ids, and i is the number of intermediate_edge_ids.

In other words, relabel the edges so that:

outgoing_edge_ids: FrozenSet[int]
swap_edges(edge_id1: int, edge_id2: int)Topology[source]

Data type of the value in a dict, see typing.ValuesView.

alias of TypeVar(‘ValueType’)

create_isobar_topologies(number_of_final_states: int)Tuple[Topology, ][source]
create_n_body_topology(number_of_initial_states: int, number_of_final_states: int)Topology[source]
get_originating_node_list(topology: Topology, edge_ids: Iterable[int])List[int][source]

Get list of node ids from which the supplied edges originate from.


edge_ids ([int]) – list of edge ids for which the origin node is searched for


a list of node ids

Return type