pytenet.opgraph.OpGraph¶
- class pytenet.opgraph.OpGraph(nodes: Sequence[OpGraphNode], edges: Sequence[OpGraphEdge], nid_terminal: Sequence[int])[source]¶
Operator graph: internal data structure for generating MPO representations.
The layout consists of alternating layers of nodes (corresponding to virtual bonds) and edges (corresponding to local operators in the MPO tensors).
- __init__(nodes: Sequence[OpGraphNode], edges: Sequence[OpGraphEdge], nid_terminal: Sequence[int])[source]¶
Methods
__init__(nodes, edges, nid_terminal)add(other)Add another graph by merging it into the current one.
add_connect_edge(edge)Add an edge to the graph, and connect nodes referenced by the edge to it.
add_edge(edge)Add an edge to the graph.
add_node(node)Add a node to the graph.
flip()Flip logical direction of the graph.
from_automaton(autop, length)Construct an operator graph from a state automaton.
from_opchains(chains, length, oid_identity)Construct an operator graph from a list of operator chains, implementing the algorithm in: Jiajun Ren, Weitang Li, Tong Jiang, Zhigang Shuai A general automatic method for optimal construction of matrix product operators using bipartite graph theory J. Chem. Phys. 153, 084118 (2020).
from_optrees(trees, length, oid_identity)Construct an operator graph from a list of operator trees.
is_consistent([verbose])Perform an internal consistency check.
merge_edges(eid1, eid2, direction)Merge paths along edges eid1 and eid2 in upstream (0) or downstream (1) direction.
node_depth(nid, direction)Determine the depth of a node (distance to terminal node in specified direction), assuming that a corresponding path exists within the graph.
remove_edge(eid)Remove an edge from the graph, and return the removed edge.
remove_node(nid)Remove a node from the graph, and return the removed node.
rename_edge_id(eid_cur, eid_new)Rename edge ID eid_cur -> eid_new.
rename_node_id(nid_cur, nid_new)Rename node ID nid_cur -> nid_new.
simplify()Simplify the graph in-place by merging edges representing the same operator.
to_matrix(opmap[, direction])Represent the logical operation of the operator graph as a matrix.
Attributes
lengthLength of the graph (distance between terminal nodes).