River crossing puzzle

A river crossing puzzle is a type of puzzle in which the object is to carry items from one river bank to another, usually in the fewest trips. The difficulty of the puzzle may arise from restrictions on which or how many items can be transported at the same time, or which or how many items may be safely left together. The setting may vary cosmetically, for example, by replacing the river by a bridge. The earliest known river-crossing problems occur in the manuscript Propositiones ad Acuendos Juvenes (English: Problems to sharpen the young), traditionally said to be written by Alcuin. The earliest copies of this manuscript date from the 9th century; it contains three river-crossing problems, including the fox, goose, and bag of beans puzzle and the jealous husbands problem.
Well-known river-crossing puzzles include:
These problems may be analyzed using graph-theoretic methods, by dynamic programming, or by integer programming.
Let G = ( V , E ) {\displaystyle G=(V,E)} be an undirected graph whose vertex set V {\displaystyle V} represents items that the farmer must carry, and whose edge set E {\displaystyle E} consists of pairs of items that conflict. For example, if a vertex v 1 {\displaystyle v_{1}} represents a goose and v 2 {\displaystyle v_{2}} the bag of beans, then the two vertices would be connected since the goose cannot be left on the same side of the river with a bag of beans. Note that the edges are undirected, as the nature of the conflict between the two items does not affect the fact that they cannot be left on the same side of the river. The object of the problem is to determine the minimum size of the boat such that a trip is feasible; this is known as the Alcuin number of G {\displaystyle G} .
Consider a successful river crossing in which the farmer first carries a subset V ′ {\displaystyle V'} of items across the river, leaving the remaining V ∖ V ′ {\displaystyle V\setminus V'} items on the shore. Because the trip is successful, there must be no conflicts in the items left onshore; ie. in G {\displaystyle G} , there are no edges in E {\displaystyle E} between any two elements of V ∖ V ′ {\displaystyle V\setminus V'} . This implies that all edges E {\displaystyle E} have one or both vertices in V ′ {\displaystyle V'} , ie. that V ′ {\displaystyle V'} is a vertex cover of G {\displaystyle G} . Therefore, the size of the boat must be at least as large as the size τ ( G ) {\displaystyle \tau (G)} of the minimum vertex cover of G {\displaystyle G} ; this forms a lower bound on the Alcuin number of G {\displaystyle G} : A l c u i n ( G ) ≥ τ ( G ) {\displaystyle Alcuin(G)\geq \tau (G)} .
On the other hand, it is possible to complete a successful trip with boat size equal to τ ( G ) + 1 {\displaystyle \tau (G)+1} . This can be achieved by requiring the members V ′ {\displaystyle V'} of a minimum vertex cover to remain on the boat at all times; these items number τ ( G ) {\displaystyle \tau (G)} , and thus leave one more space on the boat. Because there are no conflicts among any of the remaining V ∖ V ′ {\displaystyle V\setminus V'} items, they can be taken across the river one at a time in any order, occupying the one remaining space on the boat. Thus, A l c u i n ( G ) ≤ τ ( G ) + 1 {\displaystyle Alcuin(G)\leq \tau (G)+1} , forming an upper bound for A l c u i n ( G ) {\displaystyle Alcuin(G)} . Combining these together, we have τ ( G ) ≤ A l c u i n ( G ) ≤ τ ( G ) + 1 {\displaystyle \tau (G)\leq Alcuin(G)\leq \tau (G)+1} , ie. either A l c u i n ( G ) = τ ( G ) {\displaystyle Alcuin(G)=\tau (G)} or A l c u i n ( G ) = τ ( G ) + 1 {\displaystyle Alcuin(G)=\tau (G)+1} .
Csorba, Hurkens, and Woeginger proved in 2008 that determining which of A l c u i n ( G ) = τ ( G ) {\displaystyle Alcuin(G)=\tau (G)} or A l c u i n ( G ) = τ ( G ) + 1 {\displaystyle Alcuin(G)=\tau (G)+1} holds is NP-hard. Because the minimum vertex cover problem is NP-complete, it follows that computing the Alcuin number of a graph G {\displaystyle G} is NP-hard. However, for certain classes of graphs, stronger results hold. For example, for planar graphs, determining which of the two relations holds can be done in polynomial time (though determining either A l c u i n ( G ) {\displaystyle Alcuin(G)} or τ ( G ) {\displaystyle \tau (G)} remains NP-hard); for bipartite graphs, A l c u i n ( G ) {\displaystyle Alcuin(G)} and τ ( G ) {\displaystyle \tau (G)} can both be computed exactly in polynomial time.