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.

ending_node_id: Optional[int]
get_connected_nodes() → Set[int][source]
originating_node_id: Optional[int]
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.

__eq__(other: object)bool[source]

Return self==value.

static from_topology(topology: expertsystem.reaction.topology.Topology)expertsystem.reaction.topology.StateTransitionGraph[source]

Create a StateTransitionGraph from a Topology.

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

__eq__(other: object)bool[source]

Return self==value.

add_edges(edge_ids: List[int])None[source]

Add edges with the ids in the edge_ids list.

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
  • ingoing_edge_ids ([int]) – list of edge ids, that will be attached

  • node_id (int) – id of the node to which the edges will be attached

Raises
  • ValueError – if an edge not doesn’t exist.

  • ValueError – if an edge ID is already an ingoing node.

attach_edges_to_node_outgoing(outgoing_edge_ids: Iterable[int], node_id: int)None[source]
property edges
get_edges_ingoing_to_node(node_id: Optional[int]) → List[int][source]
get_edges_outgoing_from_node(node_id: Optional[int]) → List[int][source]
get_final_state_edges() → List[int][source]
get_initial_state_edges() → List[int][source]
get_intermediate_state_edges() → List[int][source]
get_originating_final_state_edges(node_id: Optional[int]) → List[int][source]
get_originating_initial_state_edges(node_id: int) → List[int][source]
get_originating_node_list(edge_ids: Iterable[int]) → List[Optional[int]][source]

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

Parameters

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

Returns

a list of node ids

Return type

[int]

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

bool

property nodes
swap_edges(edge_id1: int, edge_id2: int)None[source]
verify()None[source]

Verify if there are no dangling edges or nodes.