We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b8c7870 + 1a5ea7c commit 4aeedd6Copy full SHA for 4aeedd6
1 file changed
constr_heur.py
@@ -0,0 +1,21 @@
1
+import networkx as nx
2
+
3
4
+def find_min_fvs(G):
5
+ fvs = set()
6
+ while True:
7
+ try:
8
+ cycle = nx.find_cycle(G)
9
+ except nx.NetworkXNoCycle:
10
+ break
11
12
+ cycle_nodes = {node for e in cycle for node in e}
13
+ v = max(cycle_nodes, key=lambda x: G.degree(x))
14
+ fvs.add(v)
15
+ G.remove_node(v)
16
17
+ return fvs
18
19
20
+def get_decycling_number_constr_heur(G):
21
+ return len(find_min_fvs(G.copy()))
0 commit comments