topology¶
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:
objectStruct-like definition of an edge, used in
Topology.-
__eq__(other)¶ Method generated by attrs for class Edge.
-
-
class
FrozenDict(mapping: Optional[Mapping] = None)[source]¶ Bases:
Generic[expertsystem.reaction.topology.KeyType,expertsystem.reaction.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:
objectHelper class for the
SimpleStateTransitionTopologyBuilder.-
__eq__(other)¶ Method generated by attrs for class InteractionNode.
-
-
KeyType¶ Data type of the keys in a
dict, seetyping.KeysView.alias of TypeVar(‘KeyType’)
-
class
SimpleStateTransitionTopologyBuilder(interaction_node_set: Iterable[InteractionNode])[source]¶ Bases:
objectSimple 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[expertsystem.reaction.topology.EdgeType]Graph class that resembles a frozen
Topologywith 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
StateTransitionGraphinstances 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
StateTransitionGraphis 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, edges)[source]¶ Bases:
objectDirected 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 aTopologyis not strictly speaking a graph from graph theory, because it allows open edges, like a Feynman-diagram.-
__eq__(other)¶ Method generated by attrs for class Topology.
-
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
mis the number ofincoming_edge_ids,nis the number ofoutgoing_edge_ids, andiis the number ofintermediate_edge_ids.In other words, relabel the edges so that:
incoming_edge_idslies in the range[-1, -2, ...]outgoing_edge_idslies in the range[0, 1, ..., n]intermediate_edge_idslies in the range[n+1, n+2, ...]
-
-
ValueType¶ Data type of the value in a
dict, seetyping.ValuesView.alias of TypeVar(‘ValueType’)