graph

Graph module.

class Edge[source]

Bases: object

Struct-like definition of an edge.

__eq__(other)[source]

Return self==value.

class InteractionNode(type_name, number_of_ingoing_edges, number_of_outgoing_edges)[source]

Bases: object

Struct-like definition of an interaction node.

class StateTransitionGraph[source]

Bases: object

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)[source]

Return self==value.

add_edges(edge_ids)[source]

Add edges with the ids in the edge_ids list.

add_node(node_id)[source]

Adds a node with id node_id.

Raises

ValueError – if node_id already exists

attach_edges_to_node_ingoing(ingoing_edge_ids, node_id)[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, node_id)[source]
get_originating_node_list(edge_ids)[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]

set_graph_element_properties_comparator(comparator)[source]
swap_edges(edge_id1, edge_id2)[source]
verify()[source]

Verify if the graph is connected.

So that no dangling parts which are not connected.

are_graphs_isomorphic(graph1, graph2)[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

dicts_unequal(dict1, dict2)[source]
get_edges_ingoing_to_node(graph, node_id)[source]
get_edges_outgoing_to_node(graph, node_id)[source]
get_final_state_edges(graph)[source]
get_initial_state_edges(graph)[source]
get_intermediate_state_edges(graph)[source]
get_originating_final_state_edges(graph, node_id)[source]
get_originating_initial_state_edges(graph, node_id)[source]