Color coding: colorful paths #
A path is colorful under a coloring of the vertices when its vertices have pairwise distinct
colors. Alon, Yuster and Zwick decide whether a graph with k colors has a colorful path on k
vertices by dynamic programming over the sets of colors [AlonYusterZwick1995, Lemma 3.1]
[CyganEtAl2015, Lemma 5.5]: for each set S of colors, list the vertices v at which some
colorful path with color set exactly S ends. Such a path is the single vertex v when
S = {χ v}, and otherwise extends a colorful path with color set S \ {χ v} ending at a neighbor
of v. Color coding then finds a path on k vertices with probability at least e ^ (-k) by
running this procedure on a uniformly random coloring.
Cslib.Complexity.ColorfulPath is the problem: an instance (ColorfulPathInstance) packages a
graph, a list of colors parallel to its vertex list (Cslib.Complexity.colorOf), and a target
length (k), encoded by Cslib.Complexity.encColorfulPathInstance. The question is whether
there is a path on k vertices with pairwise distinct colors less than k. The color sets are bit
masks m < 2 ^ k, and the table (Cslib.Complexity.ColorCoding.table) has one entry per mask in
increasing order, so that the entry at m - 2 ^ χ v precedes that at m.
Resources. The table on N masks is polynomial-time with N in unary
(Cslib.Complexity.ColorCoding.computableInPolyTime_table), so the decider runs in polynomial time
on the instance padded by 2 ^ min(n, k), with n the number of distinct vertices. Padding
(Cslib.Complexity.DecidableInExpTime.of_computableInPolyTime_pad) gives a multi-tape machine
within time 2 ^ (δ k) times a polynomial in the encoded length, for some constant δ
(Cslib.Complexity.ColorfulPath_decidableInExpTime), so ColorfulPath is fixed-parameter
tractable in k (Cslib.Complexity.ColorfulPath_mem_FPT). The constant δ is not explicit: the
2 ^ k operations of the RAM analysis are not claimed for multi-tape machines.
Main definitions #
Cslib.Complexity.ColorfulPathInstance: graph, color list, and target lengthk, encoded byCslib.Complexity.encColorfulPathInstance.Cslib.Complexity.ColorfulPath: colorful paths onkvertices with colors less thank, the colors given by a list (Cslib.Complexity.colorOf).Cslib.Complexity.ColorCoding.Reaches: the colorful paths with a given color set and last vertex.Cslib.Complexity.ColorCoding.table: the dynamic programming table over color sets.Cslib.Complexity.ColorCoding.TableInput: graph, color list, and unary mask countnumSetsforCslib.Complexity.ColorCoding.computableInPolyTime_table.Cslib.Complexity.colorfulPathBool: the decider.
Main results #
Cslib.Complexity.ColorCoding.reaches_iff: the recurrence of the dynamic programming.Cslib.Complexity.ColorCoding.mem_table_getD: correctness of the table: the entry at a color set lists exactly the endpoints of colorful paths with that color set.Cslib.Complexity.ColorCoding.exists_reaches_iff: colorful paths with color set{0, …, k - 1}are the colorful paths onkvertices with colors less thank.Cslib.Complexity.colorfulPathBool_eq_true_iff: correctness of the decider.Cslib.Complexity.ColorCoding.computableInPolyTime_table: the table onNcolor sets is polynomial-time forNin unary.Cslib.Complexity.ColorfulPath_decidableInExpTime,Cslib.Complexity.ColorfulPath_mem_FPT: colorful k-Path in time2 ^ O(k)times a polynomial, and inFPT.
References #
An instance of Cslib.Complexity.ColorfulPath: a graph graph, a list of vertex
colors colors parallel to its vertex list (Cslib.Complexity.colorOf), and a target path length
length.
- graph : Graph
The input graph.
Vertex colors listed parallel to
graph.vertices(Cslib.Complexity.colorOf).- length : ℕ
The target number of vertices (and available colors).
Instances For
Binary encoding of ColorfulPathInstance as (graph, (colors, length)).
Colorful k-Path [CyganEtAl2015, Section 5.2]: the instances ⟨G, cs, k⟩ such that G has a
path on k vertices whose colors are pairwise distinct and less than k; colors are given by a
list parallel to the vertex list (Cslib.Complexity.colorOf).
The entry of the dynamic programming table at the color set m, given the entries at
smaller color sets: the vertices v with χ v ∈ m such that m = {χ v}, or some neighbor of
v is in the entry at m \ {χ v}.
The recurrence of the dynamic programming [CyganEtAl2015, Lemma 5.5]: a colorful path with
color set m ends at v exactly when χ v ∈ m, and either m = {χ v} or a colorful path with
color set m \ {χ v} ends at a neighbor of v.
Correctness of the colorful-path table [AlonYusterZwick1995, Lemma 3.1]
[CyganEtAl2015, Lemma 5.5]: below N, the entry at the color set m lists the vertices at
which some colorful path with color set m ends.
Polynomial time on padded inputs #
Parameters for building the dynamic-programming table: the input graph, vertex color list
(Cslib.Complexity.colorOf), and unary bound numSets on color-set masks.
- graph : Graph
The input graph.
Vertex colors listed parallel to
graph.vertices(Cslib.Complexity.colorOf).- numSets : ℕ
Number of color-set masks to tabulate (encoded in unary).
Instances For
Encoding of ColorCoding.TableInput with numSets in unary (encUnary).
The input of a step of the table computation: the table parameters, the table so far, and the color set in unary.
- input : TableInput
Dynamic-programming table rows accumulated for smaller color-set masks.
- mask : ℕ
Current color-set mask (encoded in unary).
Instances For
Encoding of ColorCoding.StepInput with input under encTableInput, table under
encTable, and mask in unary (encUnary).
The tuple of the fields of encStepInput.
The table on N color sets, for N in unary (ColorCoding.TableInput), is polynomial-time.
The color-coding decider for colorful k-paths [CyganEtAl2015, Lemma 5.5]: accept when
k = 0; otherwise check that k is at most the number n of distinct vertices, and that the table
on the color sets 0, …, 2 ^ k - 1 has a nonempty entry at {0, …, k - 1}.
Colorful k-Path in time 2 ^ O(k) times a polynomial [AlonYusterZwick1995, Lemma 3.1]
[CyganEtAl2015, Lemma 5.5], on multi-tape machines: the dynamic programming over color sets
(Cslib.Complexity.colorfulPathBool) runs on the input padded to length 2 ^ min(n, k). The
constant δ is not explicit; the bound 2 ^ k of the RAM analysis is not claimed.
Colorful k-Path is fixed-parameter tractable in k.