| 3 | {{{ |

| 4 | #!python |

| 5 | def random_acyclic(n, p): |

| 6 | ... g = graphs.RandomGNP(n, p) |

| 7 | ... h = DiGraph() |

| 8 | ... h.add_edges([ ((u,v) if u<v else (v,u)) for u,v,_ in g.edges() ]) |

| 9 | ... return h |

| 10 | }}} |

| 11 | |

| 12 | Before : |

| 13 | |

| 14 | {{{ |

| 15 | #!python |

| 16 | sage: g = random_acyclic(100, .2) |

| 17 | sage: %timeit g.is_directed_acyclic() |

| 18 | 125 loops, best of 3: 6.54 ms per loop |

| 19 | sage: g = random_acyclic(100, .2) |

| 20 | sage: %timeit g.is_directed_acyclic() |

| 21 | 125 loops, best of 3: 6.79 ms per loop |

| 22 | sage: g = random_acyclic(100, .2) |

| 23 | sage: %timeit g.is_directed_acyclic() |

| 24 | 125 loops, best of 3: 6.72 ms per loop |

| 25 | sage: g = random_acyclic(100, .2) |

| 26 | sage: %timeit g.is_directed_acyclic() |

| 27 | 125 loops, best of 3: 6.96 ms per loop |

| 28 | }}} |

| 29 | |

| 30 | After : |

| 31 | |

| 32 | {{{ |

| 33 | #!python |

| 34 | g = random_acyclic(100, .2) |

| 35 | %timeit g.is_directed_acyclic() |

| 36 | }}} |

| 37 | |