betaFeedback

WorksComputer Science

Graphs with Bounded Push-Pop Walk Orderings

Abstract

Consider a directed graph G and the (generally infinite) set Walks(G) of the walks in that graph. We are interested in ordering Walks(G) as w1, w2,... in a way that ensures that each walk is obtained from the previous one by a bounded number of elementary operations, namely, push operations (which add a new edge at either end of the walk) and pop operations (which remove the first or last edge of the walk). Our goal is to optimize the aforementioned bound, when it exists, in particular when imposing the additional requirement that walks must be ordered in increasing order of length. To this end, we introduce a condition on graphs inspired by earlier work, called inner-connectedness, which is testable in linear time; we show that inner-connected graphs are precisely those which admit bounded walk orderings. Focusing on such graphs, we then introduce and study the pp-rank and the pp-increasing-rank. Namely, the pp-rank of a graph is the best possible bound on the number of push-pop operations in a bounded walk ordering for that graph; and the pp-increasing-rank is the same where we further impose that shorter walks appear before longer walks in the ordering. We show that the pp-rank of inner-connected graphs is in fact always bounded by 3. The pp-increasing-rank of inner-connected graphs is also always finite, but it can be up to linear in the input graph. More precisely, we show that the pp-increasing-rank is related to a new parameter we introduce, the peripherality of graphs. In particular, for cyclic graphs, peripherality is related to the pp-increasing-rank up to multiplicative and additive constants. We last study how to compute these parameters, and show that while peripherality can be computed in polynomial time, the pp-increasing-rank itself is generally NP-hard to compute.

2012 ACM Subject Classification Mathematics of computing → Enumeration; Mathematics of computing → Graph theory

Keywords and phrases Push-pop Distance, Walk Ordering, Walk Enumeration, Combinatorial Gray Code, Graphs

Acknowledgements

Antoine Amarilli is partially supported by the project ANR-25-CE23-1215 (“Expand”); Victor Marsault and Nadime Francis by ANR-21-CE48-0015 (“VeriGraph”).

Usage of AI

We used LLMs for two purposes: bibliographic search and finding examples to build our intuition or test our conjectures. In particular, we found [15] this way, which turned out to be crucial in the proof of Proposition 6.4. In terms of examples, the only one in the final paper which was found by an LLM is given in Figure 5, in Appendix A.

A 1-orderable acyclic graph with 6 edges and its walk graph admitting a Hamiltonian path

Figure 5. A 1-orderable acyclic graph with 6 edges (a) and its walk graph (b) admitting a Hamiltonian path (orange)

Introduction

Efficient enumeration of combinatorial objects is a classical problem in theoretical computer science, with applications in exhaustive search, combinatorial generation and database query evaluation. The efficiency of enumeration algorithms is usually measured by its delay, i.e., the maximal time between consecutive outputs. While constant-delay is ideal [22], it requires writing each solution in constant time, which is unrealistic when solution size depends on input size, or when there are infinitely many solutions. To bound the delay in such cases, we adopt the approach of combinatorial Gray codes [19], where objects (e.g., binary strings, permutations or spanning trees) must be listed exactly once, with consecutive objects differing by a small change. In this setting, the time to write the output is not accounted for, following the “don’t count the output” principle of combinatorial generation [21 p. 8].

In this paper, we apply this paradigm to the enumeration of all walks in a directed graph. Our motivation comes from graph databases, where modern query languages (Cypher [8] or ISO standards GQL [11] and SQL/PGQ [10]) are based on extracting all walks satisfying navigational constraints (MATCH). Walks are usually computed and output in full, which is sometimes the bottleneck for some tasks, e.g., enumerating all shortest walks satisfying the constraints (MATCH SHORTEST, [5]). Output handling is identified as one of the current research challenges in the field [13 Sec. 7.1]: potential solutions include factorized representations [16 MN+24] and outputting only the difference between consecutive outputs. Here, we study the latter approach in the simplest setting: unlabeled graphs with no constraint on walks, where we enumerate the (possibly infinite) set of all walks. We require each produced walk to be at a bounded push-pop distance from the previous one, i.e., to be obtained by applying at most dd push operations (add an edge to either end of the walk) or pop operations (remove the first or last edge of the walk), for some d∈Nd \in\mathbb{N}.

Our first goal is to classify which graphs are orderable, i.e., admit such a bounded walk ordering, and then to quantify the best possible distance that can be achieved: we call this the pp-rank of the graph. Note that some graphs are not orderable, as shown in Figure 1; whereas others can be shown to be orderable, in Figure 2 (ignoring all edge colors and numbers for now). Next, motivated by shortest walk enumeration in graph databases, our second goal is to classify which graphs are orderable by increasing length, i.e., admit a bounded ordering with walks occurring in increasing order of length. The minimal achievable distance in that case is called pp-increasing-rank of the graph. Last, since it is sometimes harder to order “short” walks than “long” walks, our third goal is to study the eventual pp-increasing-rank, i.e., the smallest possible distance dd for which we have a walk ordering by increasing length that satisfies bound dd, except for finitely many walks. Note that graphs are orderable by increasing length if they are eventually orderable by increasing length, but their eventual pp-increasing-rank is generally smaller than their pp-increasing-rank.

Figure 1. Two graphs that are inner-disconnected, hence not orderable

Figure 2. Four graphs that are inner-connected, hence orderable by increasing length

Contributions. Our first contribution is to provide a linear-time testable characterization of graph orderability and to establish a distance bound of 3 for orderable graphs. To this end, we use inner-connectedness, inspired by a notion from [3] (see the related work paragraph for details). Their results imply that inner-disconnected graphs are not orderable. Conversely, we show that inner-connected graphs have a pp-rank of at most 3, i.e., each admits a walk ordering where consecutive walks differ by at most 3 operations.

Our second and main contribution is to study orderability by increasing length. Inner-disconnected graphs are not orderable by increasing length because they are not orderable at all. We show that, conversely, all inner-connected graphs are orderable by increasing length, with a pp-increasing-rank bound which is generally linear in the graph size.

To this end, we introduce peripherality as a graph parameter that allows us to approximate the pp-increasing-rank. Informally, the peripherality of a walk is the smallest number of edges to remove from the walk in order to be able to reach a nontrivial scc from one of its endpoints. The peripherality of a graph GG, denoted by Peri⁡(G)\operatorname{Peri}(G), is the maximal peripherality among its walks, and its eventual peripherality, denoted by EvPeri⁡(G)\operatorname{EvPeri}(G), is the maximal peripherality achieved by infinitely many walks. We show that the pp-increasing and eventual pp-increasing-rank of a cyclic graph GG are in Θ(Peri⁡(G))\Theta(\operatorname{Peri}(G)) and Θ(EvPeri⁡(G))\Theta(\operatorname{EvPeri}(G)), respectively. By contrast, the pp-increasing-rank of an acyclic graph is in O(Peri⁡(G))O(\operatorname{Peri}(G)) but there are acyclic graphs with arbitrary peripherality but constant pp-increasing-rank.

Our results on inner-connected graphs are summarized in the following theorem. We exclude trivial graphs with zero or one edge, as they do not follow the general bounds.

Theorem 1.1. Let G=(V,E)G=(V,E) be an inner-connected graph with at least two edges.

a. The pp-rank of GG belongs to [1,3][1,3].

b. The pp-increasing-rank of GG belongs to [2,6k][2,6k] if GG is acyclic, and to [k,6k][k,6k] otherwise, where k=max⁡(1,Peri⁡(G))k=\max(1,\operatorname{Peri}(G)).

c. The eventual pp-increasing-rank of GG is 00 if GG is acyclic, it is 11 if the only cycle in GG is a self-loop on a vertex with no other incident edge, and it belongs to [2k′,6k′][2k',6k'] otherwise, where k′=max⁡(1,EvPeri⁡(G))k'=\max(1,\operatorname{EvPeri}(G)).

d. We have EvPeri⁡(G)≤Peri⁡(G)<∣V∣\operatorname{EvPeri}(G)\le\operatorname{Peri}(G)<|V| and EvPeri⁡(G)<∣V∣2\operatorname{EvPeri}(G)<\frac{|V|}{2}.

The upper bounds on peripherality given in Item d are virtually tight: one can easily find infinite families of graphs with peripherality Ω(∣V∣)\Omega(|V|) (see, e.g., Figure 3); and the same remark holds for eventual peripherality. We also construct infinite graph families achieving three of the four lower bounds in Items a–c of Theorem 1.1 exactly, with the fourth off by one (Proposition 5.9). Finally, we show that peripherality and eventual peripherality can be computed in polynomial time (Propositions 6.2 and 6.3), but computing the pp-increasing-rank is NP-hard (Proposition 6.4).

Families of inner-connected cyclic graphs with high peripherality

Figure 3. Families of (inner-connected cyclic) graphs with high peripherality. Graphs in family (b) moreover have a high eventual peripherality.

Related work. The enumeration of paths and walks in graphs has been studied across multiple areas. For instance, [6] studies algorithms to enumerate the kk shortest walks between two vertices in a digraph. In database theory, [18] studies efficient enumeration of simple paths and trails that match regular expressions, and [14] studies enumeration of simple paths in graphs satisfying a restricted kind of regular expressions. More relevant to us, [2] studies constant-delay enumeration of walks that have length mm or length between ℓ\ell and mm. In their case, constant delay relies on edits to a compressed representation of the walks rather than push-pop edits on one explicit walk.

The main originality of our work is to address two goals: (1.) producing walks by performing a constant number of modifications on the walks (specifically via push-pop edits); and (2.) ordering the infinite set of all walks (rather than simple paths, or walks in a specific length range). For goal (1.), push-pop operations are considered more generally in [4], and enumeration with a constant push-pop distance specifically appears in [1]. More precisely, [1] studies the enumeration of all binary words of length ℓ\ell via push-pop operations, and can be extended to enumerate all binary words by increasing length (corresponding to goal (2.)). Since binary words correspond to walks in a single-vertex graph with two self-loops labeled 0 and 1, our work generalizes [1] to arbitrary directed graphs; by contrast, we only focus on the existence of suitable orders and not on computing them in computational models with stringent time and space bounds like in [1].

The work most closely related to ours is [3]. It studies how to enumerate the set LL of the words accepted by a deterministic finite automaton AA, while obeying a bound on the push-pop distance between consecutive words. Together with [1], this is (to our knowledge) the only existing work that addresses goals (1.) and (2.). Specifically, a linear-time-testable criterion on AA called interchangeability is presented in [3] to decide whether a bounded ordering of LL exists. Since any directed graph can be converted into a deterministic automaton (where walks in the graph correspond to the words accepted by the automaton), the results of [3] also apply to graphs. Thus, our notion of inner-connectedness specializes their interchangeability criterion, and their results directly imply that inner-disconnected graphs do not admit bounded walk orderings (Proposition 3.2). The novelty in our work relative to [3] is twofold. First, by focusing on walks in graphs, we obtain a more favorable upper bound on pp-rank: Item a of Theorem 1.1 shows a bound of 3, while their construction would give a bound of 48(∣V∣+1)248(|V|+1)^2, in fact 48∣Q∣248|Q|^2 where QQ is the automaton state set. Second, our main contributions are about ordering walks by increasing length, which is not studied by [3] and simpler in our setting (e.g., the language a(aa)∗+b(bb)∗+((a+b)(a+b))∗a(aa)^* + b(bb)^* + ((a+b)(a+b))^* is orderable but not orderable by increasing length).

Outline. The rest of the paper is organized as follows. § 4 introduces preliminary notions (graphs, walks, orderings, pp-ranks). We then introduce terminology in § 5 on object kinds and walk types, which we use to define inner-connectedness and restate the result from [3] that inner-disconnected graphs do not admit bounded walk orderings. We then focus in § 6 and § 7 on enumerating walks by increasing order of length and on the pp-increasing rank. Specifically, in § 6, after defining peripherality and eventual peripherality, we establish the upper bounds of Theorem 1.1, Items a–c, as well as Item d. We then prove in § 7 the lower bounds of Theorem 1.1, Items b and c, by introducing the criticality and eventual criticality graph parameters, and exhibit graph families that (nearly) meet the lower bounds in Items a–c. § 8 addresses computational aspects, showing that peripherality and eventual peripherality are tractable to compute while pp-increasing-rank is not. Finally, we discuss extensions and future directions in § 9.

Due to space constraints, the details of most proofs are deferred to Appendix B–E. We also provide some open problems in Appendix A.

Preliminaries

We first recall useful graph definitions and fix notations. Then we introduce the push-pop distance on walks and define our orderability notions on the walks of a graph.

Classical Graph Definitions

For every integer nn, we write [n]={0,…,n−1}[n] = \{0, \ldots, n - 1\}. By initial segment of N\mathbb{N} we refer to the whole set N\mathbb{N} or any set [n][n] for n∈Nn \in\mathbb{N}. An ordering of a countable set SS is a bijection i↦sii \mapsto s_i from an initial segment II of N\mathbb{N} to SS, written s0,s1,…s_0, s_1, \ldots or (si)i∈I(s_i)_{i \in I}; it may be finite or infinite depending on the finiteness of II. For E⊆X×XE \subseteq X \times X a binary relation over a set XX, we use the notation EnE^n, E≤nE^{\leq n}, and E∗E^* as usual: E0E^0 is the identity over XX, for n≥0n \geq0 the relation En+1E^{n+1} is {(x,z)∣∃y,x En y and y E z}\{(x,z) \mid\exists y, x\,E^n\,y \text{ and } y\,E\,z\}, the relation E≤nE^{\leq n} is ⋃i=0nEi\bigcup_{i=0}^{n} E^i, and E∗E^* is ⋃i=0∞Ei\bigcup_{i=0}^{\infty} E^i.

Graphs and walks. A directed graph (or simply graph) is a pair G=(V,E)G = (V, E) where VV is the set of vertices, and E⊆V×VE \subseteq V \times V is the set of edges. All graphs are implicitly finite unless stated otherwise. For every edge e=(s,t)∈Ee = (s,t) \in E, we call ss, resp. tt and denote by Src⁡(e)\operatorname{Src}(e), resp. Tgt⁡(e)\operatorname{Tgt}(e) the source of ee, resp. the target of ee. Note that we allow self-loops of the form (v,v)(v,v) in EE. We collectively call the elements of V∪EV \cup E the objects of GG. A subgraph of GG is a graph (V′,E′)(V', E') where V′⊆VV' \subseteq V and E′⊆EE' \subseteq E.

A walk in a graph G=(V,E)G = (V, E) is a finite sequence w=(e1,…,ek)w = (e_1, \ldots, e_k) of edges in EE with Tgt⁡(ei)=Src⁡(ei+1)\operatorname{Tgt}(e_i) = \operatorname{Src}(e_{i+1}) for each 1≤i<k1 \leq i < k; we call kk the length of ww and denote it by ∣w∣|w|. When ww is nonempty, we also say that ww is a walk from Src⁡(w):=Src⁡(e1)\operatorname{Src}(w) := \operatorname{Src}(e_1) to Tgt⁡(w):=Tgt⁡(ek)\operatorname{Tgt}(w) := \operatorname{Tgt}(e_k). The empty sequence of edges is called the empty walk and denoted by ε\varepsilon. For uu and vv two walks, if at least one of them is empty or if Tgt⁡(u)=Src⁡(v)\operatorname{Tgt}(u) = \operatorname{Src}(v), we write u⋅vu \cdot v or simply uvuv for the concatenation of uu and vv. The set of all walks in GG is denoted by Walks⁡(G)\operatorname{Walks}(G); we also use the notation Walks⁡n(G)\operatorname{Walks}_n(G), resp. Walks⁡≤n(G)\operatorname{Walks}_{\leq n}(G), resp. Walks⁡≥n(G)\operatorname{Walks}_{\geq n}(G) to denote the walks in GG of length nn, resp. at most nn, resp. at least nn.

Remark 2.1. We define walks as edge sequences rather than vertex sequences, motivated by our future application to databases. Although we restrict our analysis to graphs for the sake of clarity, this convention ensures our results generalize immediately to multigraphs, the predominant model for graph databases.

Strong connectedness. Two vertices v1v_1 and v2v_2 of a graph GG are strongly connected if either v1=v2v_1 = v_2 or there is a nonempty walk from v1v_1 to v2v_2 and a nonempty walk from v2v_2 to v1v_1. Strong connectedness is an equivalence relation, whose classes are the strongly connected components (scc for short) of GG. A graph is strongly connected if it has at most one scc. An scc is trivial if it consists of a single vertex with no self-loop. A graph is acyclic if all its sccs are trivial, and cyclic otherwise. The condensation CC of GG [9] is the acyclic graph with the sccs of GG as vertices, and with an edge from C1C_1 to C2C_2 whenever C1≠C2C_1 \ne C_2 and GG has an edge from some v1∈C1v_1 \in C_1 to some v2∈C2v_2 \in C_2.

We say that a nonempty walk starts in (resp. ends in, resp. encounters) an scc CC if its first vertex (resp. its last vertex, resp. some of its vertices) belongs to CC. We also say that a walk entirely belongs to a nontrivial scc CC if all its vertices belong to CC.

References

  1. [1]A. Amarilli, C. David, N. Francis, V. Marsault, M. Monet and Y. Strozecki. ‘Gray codes with constant delay and constant auxiliary space’. In: ICALP’26. Vol. 374. 2026. ISBN: 978-3-95977-428-4. DOI: 10.4230/LIPIcs.ICALP.2026.160.DOI
  2. [2]D. Adamson, P. Gawrychowski and F. Manea. ‘Enumerating m-length walks in directed graphs with constant delay’. In: LATIN. 2024. DOI: 10.1007/978-3-031-55598-5_3.DOI
  3. [3]A. Amarilli and M. Monet. ‘Enumerating regular languages with bounded delay’. In: STACS. 2023. DOI: 10.4230/LIPIcs.STACS.2023.8.DOI
  4. [4]F. Chung, P. Diaconis and R. Graham. ‘Universal cycles for combinatorial structures’. In: Discrete Mathematics 110.1-3 (1992). DOI: 10.1016/0012-365X(92)90699-G.
  5. [5]C. David, N. Francis and V. Marsault. ‘Distinct shortest walk enumeration for RPQs’. In: Proceedings of the ACM on Management of Data 2.2 (2024).arxiv.org/abs/2312.05505
  6. [6]D. Eppstein. ‘Finding the k shortest paths’. In: SIAM J. Comput. 28.2 (1998). DOI: 10.1137/S0097539795290477.DOI
  7. [7]T. Feder. ‘Network flow and 2-satisfiability’. In: Algorithmica 11.3 (1994). DOI: 10.1007/BF01240738.DOI
  8. [8]N. Francis, A. Green, P. Guagliardo, L. Libkin, T. Lindaaker, V. Marsault, S. Plantikow, M. Rydberg, P. Selmer and A. Taylor. ‘Cypher: An evolving query language for property graphs’. In: SIGMOD’18. ACM, 2018. DOI: 10.1145/3183713.3190657. URL: https://doi.org/10.1145/3183713.3190657.
  9. [9]F. Harary. Graph theory. Addison-Wesley, 1969.
  10. [10]ISO/IEC JTC 1/SC 32. Part 16: Property Graph Queries (SQL/PGQ). https://www.iso.org/standard/79473.html. ISO/IEC 9075-16:2023. Information technology – Database languages SQL. 2023.
  11. [11]International Organization for Standardization. GQL. https://www.iso.org/standard/76120.html. Standard ISO/IEC CD 39075. 2024.
  12. [12]J. J. Karaganis. ‘On the cube of a graph’. In: Canadian Mathematical Bulletin 11.2 (1968). DOI: 10.4153/CMB-1968-037-0.DOI
  13. [13]L. Libkin, W. Martens, F. Murlak, L. Peterfreund and D. Vrgoc. ‘Querying graph data: Where we are and where to go’. In: Companion of PODS’25. ACM, 2025. DOI: 10.1145/3722234.3725822.DOI
  14. [14]Q. Liang, D. Ouyang, F. Zhang, J. Yang, X. Lin and Z. Tian. ‘Efficient regular simple path queries under transitive restricted expressions’. In: VLDB Endowment 17.7 (2024). ISSN: 2150-8097. DOI: 10.14778/3654621.3654636.
  15. [15]T.-H. Lai and S.-S. Wei. ‘The edge Hamiltonian path problem is NP-complete for bipartite graphs’. In: Information Processing Letters 46.1 (1993). ISSN: 0020-0190. DOI: https://doi.org/10.1016/0020-0190(93)90191-B.
  16. [16]W. Martens, M. Niewerth, T. Popp, C. Rojas, S. Vansummeren and D. Vrgoc. ‘Representing paths in graph database pattern matching’. In: Proc. VLDB Endow. 16.7 (2023). DOI: 10.14778/3587136.3587151.DOI
  17. [18]W. Martens and T. Trautner. ‘Evaluation and enumeration problems for regular path queries’. In: ICDT. 2018.DOI
  18. [19][Müt23] T. Mütze. ‘Combinatorial Gray codes — An updated survey’. In: The Electronic Journal of Combinatorics Dynamic Surveys (2023). DOI: 10.37236/11023.DOI
  19. [20][NRS17] T. Ng, D. Rappaport and K. Salomaa. ‘State complexity of prefix distance’. In: Theoretical Computer Science 679 (2017).
  20. [21][Rus03] F. Ruskey. ‘Combinatorial generation’. Working Version (1j-CSC 425/520). 2003. URL: https://page.math.tu-berlin.de/~felsner/SemWS17-18/Ruskey-Comb-Gen.pdf
  21. [22][Seg14] L. Segoufin. ‘A glimpse on constant delay enumeration (invited talk)’. In: STACS. 2014.DOI
  22. [23][Sek60] M. Sekanina. ‘On an ordering of the set of vertices of a connected graph’. In: Publ. Fac. Sci. Univ. Brno 412 (1960).
  23. [24][Tar72] R. Tarjan. ‘Depth-first search and linear graph algorithms’. In: SIAM journal on computing 1.2 (1972).

Paper details

vlnc:W_8th6ubhf
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 9

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

LLMs

View statement
Looking for related papers…
Contents