Skip to content

Commit 835b5a7

Browse files
committed
Docs for Stanojevic (+added "minimal" for others' doc)
1 parent 361eb91 commit 835b5a7

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

bafna.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ def find_semidisjoint_cycle(G):
7474

7575
def get_fvs(og_G):
7676
"""
77-
Computes an approximate FVS using a weight-reduction approach described in Bafna et al.'s paper.
77+
Computes an approximate minimal FVS using a weight-reduction approach described in Bafna et al.'s paper.
7878
7979
Args:
8080
og_G (nx.Graph): The input graph.
8181
8282
Returns:
83-
set: A set of nodes forming the approximate FVS.
83+
set: A set of nodes forming the approximate minimal FVS.
8484
"""
8585
F = set()
8686
stack = []

bar_yehuda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ def get_set_covering_cycles(H, X, Y):
227227

228228
def subG_2_3(G):
229229
"""
230-
Approximates a FVS for G using Bar-Yehuda's algorithm.
230+
Approximates a minimal FVS for G using Bar-Yehuda's algorithm.
231231
232232
Args:
233233
G (nx.Graph): The input graph.
234234
235235
Returns:
236-
set: An approximated FVS for G.
236+
set: An approximated minimal FVS for G.
237237
"""
238238
if nx.is_forest(G):
239239
return set()

stanojevic.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33

44
def find_min_fvs(G):
5+
"""
6+
Finds an approximate minimal FVS for the input graph.
7+
8+
Args:
9+
G (nx.Graph): The input graph.
10+
11+
Returns:
12+
set: A set of vertices forming the approximate minimal FVS.
13+
"""
514
fvs = set()
615
while True:
716
try:
@@ -10,6 +19,7 @@ def find_min_fvs(G):
1019
break
1120

1221
cycle_nodes = {node for e in cycle for node in e}
22+
# Select the node with the highest degree to remove
1323
v = max(cycle_nodes, key=lambda x: G.degree(x))
1424
fvs.add(v)
1525
G.remove_node(v)
@@ -18,4 +28,13 @@ def find_min_fvs(G):
1828

1929

2030
def approx_decycling_number_stanojevic(G):
31+
"""
32+
Approximates the decycling number of the graph using Stanojevic's algorithm.
33+
34+
Args:
35+
G (nx.Graph): The input graph.
36+
37+
Returns:
38+
int: The approximate decycling number of the graph.
39+
"""
2140
return len(find_min_fvs(G.copy()))

0 commit comments

Comments
 (0)