aboutsummaryrefslogtreecommitdiff
path: root/PuzzleApplet.java
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2018-04-18 20:28:17 +0100
committerSimon Tatham <anakin@pobox.com>2018-04-22 16:45:37 +0100
commit4408476b7584b9a316466fe1bd10867103cddf57 (patch)
treecbfaabfe9c896e41eaf98057b057ef60f0456b5d /PuzzleApplet.java
parentef6f6427a263627de1d0fed22d8f367b15e2fb1a (diff)
downloadpuzzles-4408476b7584b9a316466fe1bd10867103cddf57.zip
puzzles-4408476b7584b9a316466fe1bd10867103cddf57.tar.gz
puzzles-4408476b7584b9a316466fe1bd10867103cddf57.tar.bz2
puzzles-4408476b7584b9a316466fe1bd10867103cddf57.tar.xz
Implementation of the Hopcroft-Karp algorithm.
This is a dedicated algorithm for finding a maximal matching in a bipartite graph. Previously I've been solving that problem in this code base using maxflow.c, modelling the graph matching problem as a restricted case of the optimal network flow problem and then using a full-strength algorithm for the latter. That's overkill, and also algorithmically wasteful - the H-K algorithm is asymptotically better, because it can find multiple augmenting paths in each pass (hence getting the maximum benefit out of each expensive breadth-first search), as a consequence of not having to worry about lower- or higher-value augmenting paths in this restricted problem. So I expect this algorithm to be faster, at least in principle or in large cases, when it takes over the jobs currently being done by maxflow. But that's not the only benefit. Another is that the data representation is better suited to the problems actually being solved, which should simplify all the call sites; a third is that I've incorporated randomisation of the generated matching into the H-K module itself, which will further save effort at each call site because they will no longer have to worry about permuting the algorithm's input - they just have to pass it a random_state and it will take care of that internally. This commit only introduces the new matching.c and builds a test utility for it. I haven't yet migrated any clients of maxflow.
Diffstat (limited to 'PuzzleApplet.java')
0 files changed, 0 insertions, 0 deletions