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
(ending_node_id: Optional[int] = None, originating_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
(*args, **kwds)[source]¶ Bases:
expertsystem.reaction.topology.Topology
,typing.Generic
Graph class that contains edges and nodes.
Similar to feynman graphs. The graphs are directed, meaning the edges are ingoing and outgoing to specific nodes (since feynman graphs also have a time axis) This class can 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.
-
compare
(other: expertsystem.reaction.topology.StateTransitionGraph, edge_comparator: Optional[Callable[[Any, Any], bool]] = None, node_comparator: Optional[Callable[[Any, Any], bool]] = None) → bool[source]¶
-
static
from_topology
(topology: expertsystem.reaction.topology.Topology) → expertsystem.reaction.topology.StateTransitionGraph[source]¶ Create a
StateTransitionGraph
from aTopology
.
-
-
class
Topology
(nodes: Optional[Set[int]] = None, edges: Optional[Dict[int, expertsystem.reaction.topology.Edge]] = None)[source]¶ Bases:
object
Directed Feynman-like graph for a state transition.
Forms the underlying topology of
StateTransitionGraph
. 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[Optional[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
¶
-