In [1]:
    
%matplotlib inline
import matplotlib.pyplot as plt
import networkx as nx
from importlib import reload
import os
import autodepgraph as adg
from autodepgraph import  AutoDepGraph_DAG
    
    
In [48]:
    
test_graph.add_node?
    
In [41]:
    
cal_True_delayed=  'autodepgraph.node_functions.calibration_functions.test_calibration_True_delayed'
test_graph = AutoDepGraph_DAG('test graph')
for node in ['A', 'B', 'C', 'D', 'E']:
    test_graph.add_node(node, 
                        calibrate_function=cal_True_delayed)
    
Some nodes require other nodes to be in a good or calibrated state. Such dependencies are defined by setting edges in the graph.
In [42]:
    
test_graph.add_edge('C', 'A')
test_graph.add_edge('C', 'B')
test_graph.add_edge('B', 'A')
test_graph.add_edge('D', 'A')
test_graph.add_edge('E', 'D')
    
In [43]:
    
# The default plotting mode is SVG 
test_graph.cfg_plot_mode = 'svg'
# Updates the monitor, in this case the svg/html page
test_graph.update_monitor()
# Updating the monitor overwrites an svg file whose location is determined by the attribute:
test_graph.cfg_svg_filename
# This attribute can safely be overwritten
    
    Out[43]:
In [44]:
    
# The html page is located at the location specified by the url. 
# The page generated based on a template when the open_html_viewer command is called. 
url = test_graph.open_html_viewer()
print(url)
    
    
In [45]:
    
# Alternatively a render in matplotlib can be drawn 
test_graph.draw_mpl()
    
    
In [46]:
    
test_graph.set_all_node_states('needs calibration')
    
In [39]:
    
test_graph.maintain_B()
    
    
In [10]:
    
test_graph.draw_mpl()
    
    
In [11]:
    
# Update the plotting monitor (default matplotlib) to show your graph
test_graph.update_monitor()
    
In [12]:
    
test_graph.set_all_node_states('needs calibration')
    
In [13]:
    
test_graph.maintain_node('E')
    
    
    Out[13]:
In [59]:
    
test_dir = os.path.join(adg.__path__[0], 'tests', 'test_data')
fn = os.path.join(test_dir, 'three_qubit_graph.yaml')
DAG = nx.readwrite.read_yaml(fn)
    
In [60]:
    
DAG.node['CZ q0-q1']
    
    Out[60]:
In [61]:
    
DAG.set_all_node_states('needs calibration')
# DAG.set_all_node_states('unknown')
DAG.update_monitor()
    
In [57]:
    
DAG._construct_maintenance_methods(DAG.nodes.keys())
    
In [58]:
    
DAG.maintain_CZ_q0_q1()