Lably
Skip to content

Lexicographic breadth-first search

Partition-based graph traversal method

  • 6 min read
  • 4 chapters

Related on Lably

Through Computer science and Pseudocode

The lexicographic breadth-first search algorithm is based on the idea of partition refinement and was first developed by Donald J. Rose, Robert E. Tarjan, and George S. Lueker (1976). A more detailed survey of the topic is presented by Corneil (2004). It has been used as a subroutine in other graph algorithms including the recognition of chordal graphs, and optimal coloring of distance-hereditary graphs.

Background

The breadth-first search algorithm is commonly defined by the following process:

  • Initialize a queue of graph vertices, with the starting vertex of the graph as the queue's only element.
  • While the queue is non-empty, remove (dequeue) a vertex v from the queue, and add to the queue (enqueue) all the other vertices that can be reached by an edge from v that have not already been added in earlier steps.

However, rather than defining the vertex to choose at each step in an imperative way as the one produced by the dequeue operation of a queue, one can define the same sequence of vertices declaratively by the properties of these vertices. That is, a standard breadth-first search is just the result of repeatedly applying this rule:

  • Repeatedly output a vertex v, choosing at each step a vertex v that has not already been chosen and that has a predecessor (a vertex that has an edge to v) as early in the output as possible.

In some cases, this ordering of vertices by the output positions of their predecessors may have ties — two different vertices have the same earliest predecessor. In this case, the order in which those two vertices are chosen may be arbitrary. The output of lexicographic breadth-first search differs from a standard breadth-first search in having a consistent rule for breaking such ties. In lexicographic breadth-first search, the output ordering is the order that would be produced by the rule:

  • Repeatedly output a vertex v, choosing at each step a vertex v that has not already been chosen and whose entire set of already-output predecessors is as small as possible in lexicographic order.

So, when two vertices v and w have the same earliest predecessor, earlier than any other unchosen vertices, the standard breadth-first search algorithm will order them arbitrarily. Instead, in this case, the LexBFS algorithm would choose between v and w by the output ordering of their second-earliest predecessors. If only one of them has a second-earliest predecessor that has already been output, that one is chosen. If both v and w have the same second-earliest predecessor, then the tie is broken by considering their third-earliest predecessors, and so on.

Applying this rule directly by comparing vertices according to this rule would lead to an inefficient algorithm. Instead, the lexicographic breadth-first search uses a set partitioning data structure in order to produce the same ordering more efficiently, just as a standard breadth-first search uses a queue data structure to produce its ordering efficiently.

Sign in to keep reading

3 more chapters are free with a Lably account.

More in Computing and communication