def test_generate_path_should_raise_when_find_cycle(self): g = nx.cycle_graph(5, nx.DiGraph()) mc.add_uniform_distr_probs_to_out_edges(g) [source, sink] = random.sample(g.nodes(), 2) self.assertRaises(s.CycleDetectedError, lambda : s.generate_path(g, source, sink))
def test_generate_path(self): p = s.generate_path(self.path_graph, self.path_graph_sources[0], self.path_graph_sinks[0]) self.assertEqual(p, self.path_graph.nodes(), "in a graph with a single path it should be returned by generate_path with probability 1")