diff options
author | Ross Barnowski <rossbar@berkeley.edu> | 2021-02-25 08:30:43 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-25 11:30:43 -0500 |
commit | 8a49999b67b4912a75452ae63b5adaec4fd1e420 (patch) | |
tree | 7583f215fb6e2c917144b6ab9e0e4d1f7ecfb8be | |
parent | e4d1483f241e9a56fbda247592710b659d29bce5 (diff) | |
download | networkx-8a49999b67b4912a75452ae63b5adaec4fd1e420.tar.gz |
Improve doc example for find_cycle. (#4639)
Modify doctest to explicitly test that the NetworkXNoCycle
exception is raised in examples.
-rw-r--r-- | networkx/algorithms/cycles.py | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/networkx/algorithms/cycles.py b/networkx/algorithms/cycles.py index 2605a0f4..483804be 100644 --- a/networkx/algorithms/cycles.py +++ b/networkx/algorithms/cycles.py @@ -392,11 +392,10 @@ def find_cycle(G, source=None, orientation=None): is also known as a polytree). >>> G = nx.DiGraph([(0, 1), (0, 2), (1, 2)]) - >>> try: - ... nx.find_cycle(G, orientation="original") - ... except: - ... pass - ... + >>> nx.find_cycle(G, orientation="original") + Traceback (most recent call last): + ... + networkx.exception.NetworkXNoCycle: No cycle found. >>> list(nx.find_cycle(G, orientation="ignore")) [(0, 1, 'forward'), (1, 2, 'forward'), (0, 2, 'reverse')] |