Esempio n. 1
0
 def _test(graph, expected_space_size):
     print("********* test on graph : {} *************".format(graph.name))
     sp = split.GraphSpliter(graph)
     nodes = get_nodes(sp, graph.ops)
     space = sp.binary_split(nodes)
     for i, s in enumerate(space):
         print('{}: {}'.format(i, split_format(sp, s)))
     assert len(space) == expected_space_size
     assert first_connected(sp, space)
Esempio n. 2
0
 def _test(graph):
     print("********* test on graph : {} *************".format(graph.name))
     sp = split.GraphSpliter(graph)
     subgraphs = sp.split(False)
     print('----- main graph -------')
     print(graph)
     for i, g in enumerate(subgraphs):
         print(' -------- subgraph {} -------'.format(i))
         print(g)
     print("--------- cost ------------")
     cost, _ = model.estimate(graph)
     _print_cost("main graph", cost)
     fc, sub_costs = model.estimate(subgraphs)
     _print_cost("Subgraphs:", fc)
     for i, cost in enumerate(sub_costs):
         _print_cost(" |_%d:\t" % (i), cost)
Esempio n. 3
0
def test_resolve_connnected_graphs():
    """Test resolve connected graphs"""
    graph = graph_5()
    sp = split.GraphSpliter(graph)
    n1 = get_nodes(sp, ['a', 'd', 'b', 'c'])
    graphs = sp.resolve_connnected_graphs(n1)
    print(graphs)
    assert len(graphs) == 1
    n2 = get_nodes(sp, ['a', 'd', 'e', 'f', 'g'])
    graphs = sp.resolve_connnected_graphs(n2)
    print(graphs)
    assert len(graphs) == 2
    n3 = get_nodes(sp, ['a', 'b', 'f'])
    graphs = sp.resolve_connnected_graphs(n3)
    print(graphs)
    assert len(graphs) == 3