Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First add some utilities for generating representative majority graphs from preferences.
Add some tests with representative majority graphs that have cycles.
By "representative" we mean a majority graph that has a corresponding expression as a list of
rankings. Not all graphs represent majority graphs. Not even all that have only one edge between
any two nodes.
The majority graph of
test_davenport_compute_preference_net_1
intest/test_davenport_prefs.c
, derived from the preference graph ofset_preference_net_1
oftest/test_helper_pref_nets.c
is excellent. It isn't under-constrained like some of the earlier tests, yet contains many cycles. The five alternatives bind together in the majority graph into one component. There are (I think) four cycles of length three and many longer cyclic traversals.The algorithm produces only one best solution for this graph, with two disagreements. It produces that solution 14,808 times. That number will be the factorial of the number of edges minus alternative edge selections eliminated by transitive closures (where selecting an edge implies other edges).
I'm actually worried that strengthening the lower bound through use of the preflow-push network will slow the algorithm down. The greedy heuristic already drills-in on the lower valued solutions quite rapidly. This seems worth exploring.
This adds a component callback to the Tarjan algorithm. The Davenport algorithm uses this callback to make the lower bound computation on each component using the preflow push network.