It turns out that each De Bruijn sequence corresponds to an Eulerian path in a

# It turns out that each de bruijn sequence corresponds

• 300
• 100% (1) 1 out of 1 people found this document helpful

This preview shows page 188 - 192 out of 300 pages.

It turns out that each De Bruijn sequence corresponds to an Eulerian path in a graph. The idea is to construct a graph where each node contains a string of n - 1 characters and each edge adds one character to the string. The following graph corresponds to the above scenario: 00 11 01 10 1 1 0 0 0 1 0 1 An Eulerian path in this graph corresponds to a string that contains all strings of length n . The string contains the characters of the starting node and all characters of the edges. The starting node has n - 1 characters and there are k n characters in the edges, so the length of the string is k n + n - 1. 178
19.4 Knight’s tours A knight’s tour is a sequence of moves of a knight on an n × n chessboard following the rules of chess such that the knight visits each square exactly once. A knight’s tour is called a closed tour if the knight finally returns to the starting square and otherwise it is called an open tour. For example, here is an open knight’s tour on a 5 × 5 board: 1 4 11 16 25 12 17 2 5 10 3 20 7 24 15 18 13 22 9 6 21 8 19 14 23 A knight’s tour corresponds to a Hamiltonian path in a graph whose nodes represent the squares of the board, and two nodes are connected with an edge if a knight can move between the squares according to the rules of chess. A natural way to construct a knight’s tour is to use backtracking. The search can be made more efficient by using heuristics that attempt to guide the knight so that a complete tour will be found quickly. Warnsdorf’s rule Warnsdorf’s rule is a simple and effective heuristic for finding a knight’s tour 3 . Using the rule, it is possible to efficiently construct a tour even on a large board. The idea is to always move the knight so that it ends up in a square where the number of possible moves is as small as possible. For example, in the following situation, there are five possible squares to which the knight can move (squares a ... e ): 1 2 a b e c d In this situation, Warnsdorf’s rule moves the knight to square a , because after this choice, there is only a single possible move. The other choices would move the knight to squares where there would be three moves available. 3 This heuristic was proposed in Warnsdorf’s book [ 69 ] in 1823. There are also polynomial algorithms for finding knight’s tours [52], but they are more complicated. 179
180
Chapter 20 Flows and cuts In this chapter, we focus on the following two problems: Finding a maximum flow : What is the maximum amount of flow we can send from a node to another node? Finding a minimum cut : What is a minimum-weight set of edges that separates two nodes of the graph? The input for both these problems is a directed, weighted graph that contains two special nodes: the source is a node with no incoming edges, and the sink is a node with no outgoing edges. As an example, we will use the following graph where node 1 is the source and node 6 is the sink: 1 2 3 6 4 5 5 6 5 4 1 2 3 8 Maximum flow In the maximum flow problem, our task is to send as much flow as possible from the source to the sink. The weight of each edge is a capacity that restricts the flow that can go through the edge. In each intermediate node, the incoming