def testPaths(self): nodes = [ Node(read) for read in ["AAA", "AGG", "GTT", "TCA"]] graph = Graph(nodes) edge = Edge(1, nodes[0], nodes[1]) self.assertFalse(graph.will_create_cycle(edge)) nodes[0].out_edges.append(edge) nodes[1].in_edges.append(edge) other_edge = Edge(0, nodes[1], nodes[0]) self.assertTrue(graph.will_create_cycle(other_edge))
def testWillCycle(self): reads = ["AAA", "AGG", "GTT"] first_node = Node("AAA") second_node = Node("AGG") third_node = Node("GGT") graph = Graph([first_node, second_node, third_node]) # add edges fs_edge = Edge(0, first_node, second_node) first_node.out_edges.append(fs_edge) second_node.in_edges.append(fs_edge) st_edge = Edge(0, second_node, third_node) second_node.out_edges.append(st_edge) third_node.in_edges.append(st_edge) # cycle edge tf_edge = Edge(0, third_node, first_node) self.assertTrue(graph.will_create_cycle(tf_edge))