forked from mfms-ncsu/Matroid-Parity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·30 lines (23 loc) · 969 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import input_parsing
import dependency_graph
import solver
import base_graph
solver.VERBOSE = True
"""
Python implementation of Stallmann's algorithm for Graphic Matroid Parity
Benjamin Peyrille (Gardes-Sol) - 2022
"""
if __name__ == "__main__":
graph, matching_ids = input_parsing.read_base_graph_from_stsh_input()
print('Input matching size', len(matching_ids))
dep_graph = dependency_graph.DependencyGraph(graph, matching_ids)
sol = solver.Solver(dep_graph)
print('\tFirst matching:', matching_ids)
while sol.improve_matching():
matching_ids = dep_graph.get_matching_from_basis()
print('\tIntermediary matching:', matching_ids)
dep_graph = dependency_graph.DependencyGraph(graph, matching_ids)
sol = solver.Solver(dep_graph)
print('Final matching size:', len(matching_ids))
print('Valid' if graph.get_spanning_forest(matching_ids) is not None else 'Invalid')
print(sorted(matching_ids))