Compute a finite set of walks for a given finite graph $g$ such that the (possibly infinitely large) set of all (finitely long) walks over the same graph can be recovered (reconstructed).
Background
I'm interested in graph query languages for matching walks. Using homomorphic pattern matching semantics in this context can lead to infinitely large result sets for many classes of graph patterns when matching walks from a cyclic graph. To avoid infinitely large results, Im trying to instead match a finite set of walks from which the full (possibly) infinite set of walks can be recovered (reconstructed), i.e. a finite set of walks that is a compressed representation of the total result set.
Questions
Given any directed Graph $G$ and the set of all possible walks $W$ over $G$ (i.e. the set of all non-empty, finite-length sequences of nodes that are sequentially connected in $G$), define the smallest finite set of walks $W_f \subset W$ in terms of
(1) a predicate function $f : W \to Boolean$ such that for any $w \in W$ it holds that if $f(w)$ is $true$ it follows that $f(w')$ is $true$ for all $w'$ from $W$ that contain $w$.
together with
(2) a reconstruction function $g_f : W \to 2^W$ that gives rise to
$W_{g_f} = \{ w' | w \in W_f $ and $w' \in g(w) \}$
such that $W_{g_f} = W$, i.e. $g_f$ allows reconstructing (recovering) the set of all walks $W$, and
(3) $f$, $g_f$ do not depend in any way on $G$ or $W$.
Are there any $f$, $g$ that fulfill the given requirements for any directed graph $G$? Is $W_f$ uniquely defined or are there multiple solutions of the same size? Which reconstruction function $g_f$ produces the smallest amount of overlaps? An overlap $o$ between different $w$, $w'$ from $W_f$ is any walk $o \in g(w) \cap g(w')$.
Example 1
(a)->(b)
$W = \{ a, ab, b \}$
$W_f = W$
$f(w) = true$ for all $w$.
$g(w) = \{ w \}$ for all $w$.
Example 2
(a)->(b)->(c)
^
|
v
(d)
$W$ is now infinite due to the cycle between $b$ and $d$.
$\{ ab, abc, abdbdbd, dbdbc \}$ are some valid walks from $W$.
Now here's an idea what $f$ and $g$ could look like:
$f(w)$ is true if $w$ does not contain the same cycle twice in any consecutive sequence of cycles in $w$ that all start at the same node and do not overlap otherwise.
$W_f = \{ a, ab, abc, bc, c, abd, bd, abdb, bdb, abdbc, bdbc, db, dbc, dbd \}$
$g(w)$ returns all $w'$ constructed by duplicating cycles already present in $w$ (i.e. produces an infinite set).