Esempio n. 1
0
 def cascade(self):
     g = DiGraph()
     g.add_cycle([0, 1, 2, 3])
     g.add_cycle([2, 3, 4, 5])
     g.add_cycle([4, 5, 6, 7])
     set_edge_and_node_weights(g, extra_guesses_at=[1, 3, 5, 7])
     return g, {1}
Esempio n. 2
0
    def test_hamiltonians(self):
        graph = DiGraph()
        nodes = list(range(3))
        graph.add_cycle(nodes)
        rotations = {tuple(nodes[i:] + nodes[:i]) for i in nodes}

        self.assertEqual(set(map(tuple, hamiltonians(graph))), rotations)
        self.assertTrue(tuple(find_hamiltonian(graph)) in rotations)
Esempio n. 3
0
 def loop(self):
     # This only has trivial SISO nodes and no hints
     g = DiGraph()
     g.add_cycle([0, 1])
     g.node[0]['weight'] = 1
     g.node[1]['weight'] = 1
     g[0][1]['weight'] = 1
     g[1][0]['weight'] = 1
     return g, set()
Esempio n. 4
0
 def process(self):
     g = DiGraph()
     g.add_cycle([1, 2, 3])
     g.add_cycle([0, 1, 2, 4])
     g.add_cycle([5, 6, 7])
     g.add_cycle([0, 1, 2, 4, 5, 6, 8])
     hints = {0, 8}
     set_edge_and_node_weights(g, extra_guesses_at=[2, 4, 6, 8])
     return g, hints