Skip to content

Commit

Permalink
Fixed the citation in dominance.py [Issue networkx#7522] (networkx#…
Browse files Browse the repository at this point in the history
…7524)

Update format and link to dominance paper

---------

Co-authored-by: Gilles Peiffer <gilles.peiffer.yt@gmail.com>
Co-authored-by: Ross Barnowski <rossbar@caltech.edu>
  • Loading branch information
3 people authored Jul 1, 2024
1 parent fe5e260 commit cde19f9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
12 changes: 6 additions & 6 deletions networkx/algorithms/dominance.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def immediate_dominators(G, start):
References
----------
.. [1] K. D. Cooper, T. J. Harvey, and K. Kennedy.
A simple, fast dominance algorithm.
Software Practice & Experience, 4:110, 2001.
.. [1] Cooper, Keith D., Harvey, Timothy J. and Kennedy, Ken.
"A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""
if start not in G:
raise nx.NetworkXError("start is not in G")
Expand Down Expand Up @@ -118,9 +118,9 @@ def dominance_frontiers(G, start):
References
----------
.. [1] K. D. Cooper, T. J. Harvey, and K. Kennedy.
A simple, fast dominance algorithm.
Software Practice & Experience, 4:110, 2001.
.. [1] Cooper, Keith D., Harvey, Timothy J. and Kennedy, Ken.
"A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""
idom = nx.immediate_dominators(G, start)

Expand Down
33 changes: 17 additions & 16 deletions networkx/algorithms/tests/test_dominance.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,20 @@ def test_unreachable(self):
}

def test_irreducible1(self):
# Graph taken from Figure 2 of
# K. D. Cooper, T. J. Harvey, and K. Kennedy.
# A simple, fast dominance algorithm.
# Software Practice & Experience, 4:110, 2001.
"""
Graph taken from figure 2 of "A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""
edges = [(1, 2), (2, 1), (3, 2), (4, 1), (5, 3), (5, 4)]
G = nx.DiGraph(edges)
assert nx.immediate_dominators(G, 5) == {i: 5 for i in range(1, 6)}

def test_irreducible2(self):
# Graph taken from Figure 4 of
# K. D. Cooper, T. J. Harvey, and K. Kennedy.
# A simple, fast dominance algorithm.
# Software Practice & Experience, 4:110, 2001.
"""
Graph taken from figure 4 of "A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""

edges = [(1, 2), (2, 1), (2, 3), (3, 2), (4, 2), (4, 3), (5, 1), (6, 4), (6, 5)]
G = nx.DiGraph(edges)
result = nx.immediate_dominators(G, 6)
Expand Down Expand Up @@ -113,10 +114,10 @@ def test_unreachable(self):
assert nx.dominance_frontiers(G, n // 2) == {i: set() for i in range(n // 2, n)}

def test_irreducible1(self):
# Graph taken from Figure 2 of
# K. D. Cooper, T. J. Harvey, and K. Kennedy.
# A simple, fast dominance algorithm.
# Software Practice & Experience, 4:110, 2001.
"""
Graph taken from figure 2 of "A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""
edges = [(1, 2), (2, 1), (3, 2), (4, 1), (5, 3), (5, 4)]
G = nx.DiGraph(edges)
assert dict(nx.dominance_frontiers(G, 5).items()) == {
Expand All @@ -128,10 +129,10 @@ def test_irreducible1(self):
}

def test_irreducible2(self):
# Graph taken from Figure 4 of
# K. D. Cooper, T. J. Harvey, and K. Kennedy.
# A simple, fast dominance algorithm.
# Software Practice & Experience, 4:110, 2001.
"""
Graph taken from figure 4 of "A simple, fast dominance algorithm." (2006).
https://hdl.handle.net/1911/96345
"""
edges = [(1, 2), (2, 1), (2, 3), (3, 2), (4, 2), (4, 3), (5, 1), (6, 4), (6, 5)]
G = nx.DiGraph(edges)
assert nx.dominance_frontiers(G, 6) == {
Expand Down

0 comments on commit cde19f9

Please sign in to comment.