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
.-
__eq__
(other)¶ Method generated by attrs for class Edge.
-
-
class
InteractionNode
(type_name: str, number_of_ingoing_edges: int, number_of_outgoing_edges: int)[source]¶ Bases:
object
Struct-like definition of an interaction node.
-
class
SimpleStateTransitionTopologyBuilder
(interaction_node_set: Sequence[expertsystem.reaction.topology.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_graphs
(number_of_initial_edges: int, number_of_final_edges: int) → List[expertsystem.reaction.topology.Topology][source]¶
-
extend_graph
(graph: Tuple[expertsystem.reaction.topology.Topology, Sequence[int]]) → List[Tuple[expertsystem.reaction.topology.Topology, List[int]]][source]¶
-
-
class
StateTransitionGraph
(topology: expertsystem.reaction.topology.Topology, node_props: Dict[int, expertsystem.reaction.quantum_numbers.InteractionProperties] = None, edge_props: Dict[int, _EdgeType] = None)[source]¶ Bases:
typing.Generic
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: expertsystem.reaction.topology.StateTransitionGraph, edge_comparator: Optional[Callable[[_EdgeType, _EdgeType], bool]] = None, node_comparator: Optional[Callable[[expertsystem.reaction.quantum_numbers.InteractionProperties, expertsystem.reaction.quantum_numbers.InteractionProperties], bool]] = None) → bool[source]¶
-
property
edges
¶
-
evolve
(node_props: Optional[Dict[int, expertsystem.reaction.quantum_numbers.InteractionProperties]] = None, edge_props: Optional[Dict[int, _EdgeType]] = None) → expertsystem.reaction.topology.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) → expertsystem.reaction.quantum_numbers.InteractionProperties[source]¶
-
property
nodes
¶
-
-
class
Topology
(nodes: Optional[Set[int]] = None, edges: Optional[Mapping[int, expertsystem.reaction.topology.Edge]] = None)[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.-
add_node
(node_id: int) → None[source]¶ Adds a node with id node_id.
- Raises
ValueError – if node_id already exists
-
attach_edges_to_node_ingoing
(ingoing_edge_ids: Iterable[int], node_id: int) → None[source]¶ Attach existing edges to nodes.
So that the are ingoing to these nodes.
- Parameters
- Raises
ValueError – if an edge not doesn’t exist.
ValueError – if an edge ID is already an ingoing node.
-
property
edges
¶
-
get_originating_node_list
(edge_ids: Iterable[int]) → List[int][source]¶ Get list of node ids from which the supplied edges originate from.
-
is_isomorphic
(other: expertsystem.reaction.topology.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
-
property
nodes
¶
-