Graph
QuICT.qcda.optimization.cnot_without_ancilla.graph ¶
Bipartite ¶
Bases: Graph
A bipartite graph
Attributes:
-
left(List) –left side of bipartite graph
-
right(List) –right side of bipartite graph
Construct a bipartite graph. There should be no overlap between left and right
Parameters:
-
left(List[int]) –left side of bipartite graph
-
right(List[int]) –right side of bipartite graph
-
edges(List[Edge], default:None) –Specify edge between left and right. The next field of Edge could be invalid here.
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
Edge ¶
A simple container for edges in a graph
Attributes:
-
start(int) –start point of the edge
-
end(int) –end point of the edge
-
valid(bool) –attribute of the edge indicating whether it's valid
-
color(int) –color of the edge
-
next(int) –next fake pointer in edge list
Construct an edge
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
Graph ¶
A simple container for graphs. The graph is directed.
For undirected graph, you must add reverse edges just after
adding an edge. For example, add_edge(a,b), add_edge(b, a).
Therefore, eid of reverse edge is exactly eid^1.
Construct a graph. It's empty if both nodes and edges are None.
Parameters:
-
nodes(List[int], default:None) –A list of all nodes. In most cases, it should be a continuous list which contains sequential integers.
-
edges(List[Edge], default:None) –A list of all edges
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
add_edge ¶
Add an edge from start end with marked value
Parameters:
-
start(int) –start point
-
end(int) –end point
-
valid(bool, default:True) –if valid
-
color(int, default:-1) –color of the edge
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
get_any_degree ¶
Return degree of any node. User should not expect return value of this function to be special unless it's a regular graph.
Returns:
-
int(int) –degree of any node.
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
get_degree ¶
Get degree of node x
Parameters:
-
x(int) –Index of node to be queried.
Returns:
-
int(int) –degree of node x.
Source code in QuICT/qcda/optimization/cnot_without_ancilla/graph.py
get_max_degree ¶
Get maximum degree of the graph
Returns:
-
int(int) –max degree
get_max_degree_node ¶
Get the index of node with maximal degree. Returns: int: Node index.