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 (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:


 * The fox, goose, and bag of beans puzzle, in which a farmer must transport a fox, goose and bag of beans from one side of a river to another using a boat which can only hold one item in addition to the farmer, subject to the constraints that the fox cannot be left alone with the goose, and the goose cannot be left alone with the beans. Equivalent puzzles have also been stated involving a fox, chicken, and bag of grain, or a wolf, goat, and cabbage, etc.
 * The jealous husbands problem, in which three married couples must cross a river using a boat which can hold at most two people, subject to the constraint that no woman can be in the presence of another man unless her husband is also present. This is similar to the missionaries and cannibals problem, in which three missionaries and three cannibals must cross the river, with the constraint that at any time when both missionaries and cannibals are standing on either bank, the cannibals on that bank may not outnumber the missionaries.
 * The bridge and torch problem.
 * Propositio de viro et muliere ponderantibus plaustrum. In this problem, also occurring in Propositiones ad Acuendos Juvenes, a man and a woman of equal weight, together with two children, each of half their weight, wish to cross a river using a boat which can only carry the weight of one adult.

These problems may be analyzed using graph-theoretic methods, by dynamic programming, or by integer programming.

Graph theoretic formulation
Let $$G=(V, E)$$ be an undirected graph whose vertex set $$V$$ represents items that the farmer must carry, and whose edge set $$E $$ consists of pairs of items that conflict. For example, if a vertex $$v_1$$ represents a goose and $$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$$.

Consider a successful river crossing in which the farmer first carries a subset $$V'$$ of items across the river, leaving the remaining $$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$$, there are no edges in $$E$$ between any two elements of $$V \setminus V'$$. This implies that all edges $$E$$ have one or both vertices in $$V$$, ie. that $$V$$ is a vertex cover of $$G$$. Therefore, the size of the boat must be at least as large as the size $$\tau(G)$$ of the minimum vertex cover of $$G$$; this forms a lower bound on the Alcuin number of $$G$$: $$Alcuin(G) \ge \tau(G)$$.

On the other hand, it is possible to complete a successful trip with boat size equal to $$\tau(G) +1$$. This can be achieved by requiring the members $$V'$$ of a minimum vertex cover to remain on the boat at all times; these items number $$\tau(G)$$, and thus leave one more space on the boat. Because there are no conflicts among any of the remaining $$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, $$Alcuin(G) \le \tau(G) + 1$$, forming an upper bound for $$Alcuin(G)$$. Combining these together, we have $$\tau(G) \le Alcuin(G) \le \tau(G) + 1$$, ie. either $$Alcuin(G) = \tau(G)$$ or $$Alcuin(G) = \tau(G) + 1$$.

Csorba, Hurkens, and Woeginger proved in 2008 that determining which of $$Alcuin(G) = \tau(G)$$ or $$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$$ 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 $$Alcuin(G)$$ or $$\tau(G)$$ remains NP-hard); for bipartite graphs, $$Alcuin(G)$$ and $$\tau(G)$$ can both be computed exactly in polynomial time.