# Path: sdopt/parsers/dag_parser.py
# def read_problem(filename, crosscheck_nl=True, show_sparsity=True):
#     with lines_of(filename) as lines:
#         problem = parse(lines)
#     setup(problem)
#     if crosscheck_nl:
#         nl_filename = filename[:-4]+'.nl' # filename.dag -> filename.nl
#         bsp = read_flattened_ampl(nl_filename, show_sparsity)
#         crosscheck_sparsity_pattern(problem, bsp.csr_mat)
#         crosscheck_names(problem, bsp.row_names, bsp.col_names)
#     return problem
# 
# Path: sdopt/representation/dag_util.py
# def plot(dag):
#     from matplotlib import pyplot as plt
#     
#     node_labels = nx.get_node_attributes(dag, NodeAttr.display)
#     edge_labels = nx.get_edge_attributes(dag, 'weight')
# 
#     dag_copy = dag.to_directed()
#     for _, d in dag_copy.nodes_iter(data=True):
#         d.clear()
#     # FIXME Why does this try to copy attributes that it cannot?
#     positions = nx.graphviz_layout(dag_copy, prog='dot')
# 
#     nx.draw_networkx_edge_labels(dag, positions, edge_labels, rotate=False)
#     nx.draw_networkx(dag, pos=positions, labels=node_labels, node_size=800)
#     mng = plt.get_current_fig_manager()
#     # TODO Post a wrapper to Code Review?
#     #mng.full_screen_toggle()   
#     mng.resize(1865,1025)
#     plt.show()
# 
# Path: sdopt/datagen/paths.py
# DATADIR = join(_ROOT, 'data')


from os.path import join
from .parsers.dag_parser import read_problem
from .representation.dag_util import plot
from .datagen.paths import DATADIR
from __future__ import print_function


def run():
    p = read_problem(join(DATADIR, 'JacobsenDbg.dag'))
    plot(p.dag)
    print()

# Path: sdopt/parsers/dag_parser.py
# def read_problem(filename, crosscheck_nl=True, show_sparsity=True):
#     with lines_of(filename) as lines:
#         problem = parse(lines)
#     setup(problem)
#     if crosscheck_nl:
#         nl_filename = filename[:-4]+'.nl' # filename.dag -> filename.nl
#         bsp = read_flattened_ampl(nl_filename, show_sparsity)
#         crosscheck_sparsity_pattern(problem, bsp.csr_mat)
#         crosscheck_names(problem, bsp.row_names, bsp.col_names)
#     return problem
# 
# Path: sdopt/representation/dag_util.py
# def plot(dag):
#     from matplotlib import pyplot as plt
#     
#     node_labels = nx.get_node_attributes(dag, NodeAttr.display)
#     edge_labels = nx.get_edge_attributes(dag, 'weight')
# 
#     dag_copy = dag.to_directed()
#     for _, d in dag_copy.nodes_iter(data=True):
#         d.clear()
#     # FIXME Why does this try to copy attributes that it cannot?
#     positions = nx.graphviz_layout(dag_copy, prog='dot')
# 
#     nx.draw_networkx_edge_labels(dag, positions, edge_labels, rotate=False)
#     nx.draw_networkx(dag, pos=positions, labels=node_labels, node_size=800)
#     mng = plt.get_current_fig_manager()
#     # TODO Post a wrapper to Code Review?
#     #mng.full_screen_toggle()   
#     mng.resize(1865,1025)
#     plt.show()
# 
# Path: sdopt/datagen/paths.py
# DATADIR = join(_ROOT, 'data')


# Path: sdopt/demo.py
from os.path import join
from .parsers.dag_parser import read_problem
from .representation.dag_util import plot
from .datagen.paths import DATADIR

from __future__ import print_function


def run():
    p = read_problem(join(DATADIR, 'JacobsenDbg.dag'))
    plot(p.dag)
    print()

    read_problem(join(DATADIR, 'ex9_2_8.txt'), crosscheck_nl=False)