10

Let $G$ be a directed graph with $n$ vertices, and let there be vertices $s$ (source) and $t$ (sink) such that

  1. Every vertex is reachable from $s$, and can reach $t$. (I.e., for every $v$, there is a path from $s$ to $t$ going through $v$.)

  2. For every pair of vertices $u, v$ and for every integer $k \ge 0$, there is at most one path of length $k$ from $u$ to $v$.

What is the maximum number of edges in $G$?

I'm mostly interested in the asympototic growth of the answer -- is there a linear (in $n$) upper bound on the number of edges? Can it be quadratic?


Observations:

  • Without condition (1), the number of edges can be quadratic. We can split the $n$ vertices into two halves of $(n/2)$ vertices each, and connect every pair from the first to the second, yielding $\frac{n^2}{4}$ edges.

  • The question is related to the theory of finite automata. The directed graph with $n$ vertices and $s, t$ is an NFA over a singleton alphabet $\{a\}$, with no epsilon transitions, and with only one initial state and accepting state. Condition (1) says that the automaton is trim (this word indicates that all unnecessary states have been removed). Condition (2) says that the automaton is unambiguous. Thus the question is a special case of this more general problem: find the maximum possible number of transitions in a trim, unambiguous NFA.

  • Although this seems needlessly obscuring, we can equivalently state conditions (1) and (2) using the adjacency matrix of $G$. Let $A$ be the adjacency matrix, and let $e_1, e_2, \ldots, e_n$ be the standard basis, with $s = e_1$ and $t = e_n$ WLOG. Then the conditions are:

    1. For all $i$, there exist integers $k, l \ge 0$ such that $e_1^T A^k e_i e_i^T A^l e_n > 0$.

    2. For all $1 \le i, j \le n$ and $k \ge 0$, $e_i^T A^k e_j \le 1$.

    In particular, condition (2) says that $A^k$ is a matrix of $0$s and $1$s, for all $k$.

    The number of edges in $G$ is then $u^T A u$, where $u = e_1 + e_2 + \cdots + e_n$.

  • Are you thinking of $k$ here as fixed or growing with $n$? For example, it seems like you could get something like $\frac{n^2}{4k^2}$ by drawing all edges between two sets of size $\frac{n}{2k}$ and adding disjoint paths of length $k$ from $s$ to each vertex in one set and from each vertex in the other set to $t$. This is quadratic in $n$ for fixed $k$, but not so good if $k$ is the same order as $n$. – Kevin P. Costello Sep 21 '17 at 19:45
  • @KevinCostello I meant statement (2) to be true for all $k$. I edited it now in case the wording was unclear. – Caleb Stanford Sep 22 '17 at 03:17
  • @Irvan Nice approach. Why only a linear number of edges once the path in (1) is unique? I can't rule out still there being 1 + 2 + 3 + ... + (n-1) edges. – Caleb Stanford Sep 24 '17 at 16:48
  • @6005 I've elaborated the partial answer in a separate answer. Also "Remove as many edges in GG as possible so that the paths described in (1) is unique" was wrong, it's fixed in the answer. I hope it's clear! – Irvan Sep 26 '17 at 15:16

1 Answers1

2

By condition (1), there exists a subgraph $S_s$ of $G$ that is a rooted tree from $s$ to every other node. Similarly there exists another subgraph $S_t$ of $G$ that is a (reverse) tree going from each node to $t$. Let $S$ be the union of $S_s$ and $S_t$. Clearly $S$ has a linear number of edges.

Whenever we add an edge to $S$, we will have a new path going from $s$ to $t$ whose length is at most $2n$ (if we add an edge $u \to v$, this path will be $s \to \cdots \to u \to v \to \cdots \to t$). By condition (2), we can thus add at most $O(n)$ such edges. Since we can construct $G$ by repeatedly adding new edges to $S$, $G$ must have a linear number of edges.

Irvan
  • 2,278
  • Yeah, I think this works. For the linear number of edges, we greedily create a tree from s, and a tree from t until no tree can be extended. Since every vertex v is reachable from s, v must be contained in the tree from s (or else we could consider the path from s to v, and the first edge which goes from the tree from s to outside that tree). Similarly for t. So both trees contain all vertices. And then we can remove all other edges preserving that the paths in (1) still exist, and we get a union of two rooted trees like you describe. – Caleb Stanford Sep 26 '17 at 17:59
  • Now, when we add an edge to G, say the edge $(u,v)$, we get at least one more path from $s$ to $t$ (by going from $s$ to $u$, and then from $v$ to $t$). If we were not in a DAG, this path might conceivably contain a cycle. Because there are no cycles, however, the path actually does not repeat vertices and its length is upper bounded by $n$. – Caleb Stanford Sep 26 '17 at 18:05
  • I am sorry the bounty expired before I had a chance to read the answer (did not see it was about to clock out). I have given you an upvote. – Caleb Stanford Sep 26 '17 at 18:05
  • @6005 you're right, it seems that this proof works for not necessarily acyclic graphs as well with the following modification: "Since the lengths of these paths is at most $n$" becomes "The length of the shortest of these new paths is at most $n$". – Irvan Sep 27 '17 at 09:11
  • not quite, no. Removing the cycle could also remove the important new edge u v. I think the shortest path containing u v still has length at most 2n, though. – Caleb Stanford Sep 27 '17 at 16:05
  • @6005 Whoops, you're right. Length is maximum 2n. – Irvan Sep 27 '17 at 16:26