def create_random_dag(size):
    G = nx.DiGraph()
    nodes = range(size) 
    G.add_nodes_from(nodes)
    for i in xrange(size):
        distribution = utilities.get_circular_distribution(size - i - 1)
        for j, probability in zip(xrange(i + 1, size), distribution):
            G.add_edge(nodes[i], nodes[j], prob = probability)
    return G
 def test_pick_from_distr(self):
     d = mc.pick_from_distr(mc.get_circular_distribution(5))
     self.assertGreaterEqual(d, 0)
     self.assertLess(d, 5)
 def test_get_circular_distribution(self):
     distribution = mc.get_circular_distribution(5)
     self.assertEqual(len(distribution), 5)
     self.assertAlmostEqual(sum(distribution), 1.0)
     self.assertTrue(all([x > 0.0 for x in distribution]), "All elements from distribution should be greater than 0.0")