<p><strong>[Revised.]</strong> I think that there has been a little confusion about what I was referring to in my original answer. I am revising it in order to better describe the result. </p>

<p>Note that your representation will only be capable of representing transitively-closed DAGs, <em>i.e.</em>&nbsp;partial orders; and this representation is a previously-studied one for partial orders. For instance, <a href="http://epubs.siam.org/sima/resource/1/sjmael/v3/i3/p351_s1" rel="nofollow noreferrer">a paper by Mihalis Yannakakis</a> shows that determining whether a partial order (equivalently, a transitively-closed digraph) has such a representation is <strong>NP</strong>-complete for <em>n</em>&nbsp;&ge;&nbsp;3, but feasible if <em>n</em>&nbsp;&le;&nbsp;2.</p>

<hr>

<p>Also, because the representation describes transitively closed DAGs, the body of research on the <em>Transitive Closure</em> problem is a reasonable place to look for related representations. <a href="https://cstheory.stackexchange.com/revisions/215e2e49-675d-4ddc-a836-bda57afd2031/view-source">My original response</a> described a representation which, as it turned out, was strictly less general than the representation in terms of vectors. However, your representation has some similarities to the <strong>tree-cover</strong> representation of transitively closed DAGs (see <a href="http://portal.acm.org/citation.cfm?id=66950" rel="nofollow noreferrer">Efficient management of transitive relationships in large data and knowledge bases</a>: also described briefly in <a href="http://research.microsoft.com/pubs/144985/TODSFinal.pdf" rel="nofollow noreferrer">this article</a>).</p>

<ul>
<li><p>Without loss of generality, if the DAG has more than one 'source' (vertex with in-degree 0), add a virtual 'root' which can reach all of the sources. The entire DAG then has a spanning tree.</p></li>
<li><p>For each vertex, define an interval [&nbsp;<em>a<sub>v</sub></em>&nbsp;,&nbsp;<em>b<sub>v</sub></em>&nbsp;] to each vertex <em>v</em>, in such a way that the interval at each node contains the intervals of all its descendants. (For instance, the upper bound <em>b<sub>v</sub></em> for each <em>v</em> can be taken to be the post-fix order of the vertex in the tree; the lower bound <em>a<sub>v</sub></em> is the minimum of these post-fix values for the sub-tree.)</p></li>
<li><p>To represent directed edges which are not in the tree, each node keeps a list of the intervals of the different nodes which are reachable from it. (For any given sub-tree which is reachable from a given node, it suffices to record the interval belonging to the root of that sub-tree.)</p></li>
</ul>

<p>Thus, the in-bound edges of each vertex is represented by the single interval [&nbsp;<em>a<sub>v</sub></em>&nbsp;,&nbsp;<em>b<sub>v</sub></em>&nbsp;]&nbsp;, and its outbound edges are represented by a union of disjoint intervals which strictly contain the intervals of vertices that it can reach.</p>

<p>Some observations:</p>

<ol>
<li><p>The vector representation is related to the interval nesting condition by using higher dimensional "intervals". Without loss of generality, the length <em>n</em> of the array <strong>x</strong><sup><em>v</em></sup> at each vertex is even (by buffering with a final dummy co-ordinate if needed). Let <em>m</em>&nbsp;=&nbsp;<em>n</em>/2. Partition the coefficients as
$$ \mathbf x^v \;=\; [ \;a^v_1 \;,\; \ldots \;,\; a^v_m \;;\; c^v_1 \;,\; \ldots \;,\; c^v_m \;] $$
For each 1&nbsp;&le;&nbsp;<em>j</em>&nbsp;&le;&nbsp;<em>m</em>&nbsp;, let $$ U_j = \left( \max_v \;\; a^v_j \right) + \left( \max_v \;\; c^v_j \right). $$ Then, we may define for each node an <em>m</em>-fold cartesian product of intervals,
$$ I^v \;=\; [\;a^v_1\;,\; U_1-c^v_1 \;] \times \cdots \times [\;a^v_m\;,\; U_m-c^v_m \;]. $$
Two such "$m$-dimensional intervals" nest if and only if the corresponding vectors have the appropriate ordering relations. It is trivial to verify that the intervals nest only if the corresponding vectors are ordered; for the converse, we depend on none of the coefficients in the graph being larger than the corresponding bounds <em>U<sub>j</sub></em>&nbsp;.</p></li>
<li><p>It is not clear to me whether the representation by vectors and by tree-covers are efficiently interconvertible; however it is easy to show that the case <em>n</em>&nbsp;=&nbsp;2 corresponds exactly to the representation of directed trees in terms of tree-covers (<em>i.e.</em>&nbsp;the two representations are efficiently and reversibly inter-convertible, essentially by the technique I described above). Thus, the dimension may in some sense correspond to how tree-like the digraph is.</p></li>
</ol>

CC BY-SA 2.5
2011-04-04T15:26:31.720Z
Niel, I don't know if you saw my answer: the key notion is the "dimension": there's a relatively simple argument that shows that the dimension of a lattice is at most its width, and indeed your example shows that this inequality can be made quite loose (2 vs n)
Suresh Venkat
CC BY-SA 2.5
2011-04-04T15:52:04.490Z
@Suresh: it turns out that there is possibly more than one meaning of the phrase "chain decomposition". The literature on intersections of linear orders describe those orders as "chains"; but this is different from the vertex-disjoint decomposition into "chains" in the graph which I described. But never mind; if everyone assumed that I meant the former instead of the latter, I can revise my answer correspondingly.
Niel de Beaudrap
CC BY-SA 2.5
2011-04-03T16:47:47.683Z
2011-04-04T16:14:43.980Z
2017-04-13T12:32:28.743Z
Niel de Beaudrap
<p>As Niel noted, your representation is transitively closed. If we go from a digraph to its transitive closure (which is a partial order) then your representation is used to define the dimension of a partial order. </p>

<p>Specifically, the dimension of a partial order corresponds to the minimum number of "coordinates" you need in your representation to correctly capture the ordering relationship among elements. </p>

CC BY-SA 2.5
2011-04-03T19:13:59.287Z
2011-04-04T15:26:41.643Z
2011-04-04T15:26:41.643Z
Suresh Venkat
<blockquote>
  <p>Has such a representation been thought up before?</p>
</blockquote>

<p>For partial orders, yes. A lot of tableaux/sequent calculi for modal logics have used lists of integers to represent "possible worlds" and incorporate the relationships between worlds. It's an old technique (I think first going back to Fitting's work, I think in <a href="http://openlibrary.org/books/OL4441316M/Intuitionistic_logic_model_theory_and_forcing">"Intuitionistic logic, model theory and forcing"</a> or <a href="http://openlibrary.org/books/OL22333319M/Proof_methods_for_modal_and_intuitionistic_logics">Proof methods for modal and intuitionistic logics</a>). </p>

CC BY-SA 2.5
2011-04-03T23:37:10.917Z
2011-04-03T23:37:10.917Z
Rob
<p>I had an idea for a way of representing DAGs, it's very easy to explain:</p>

<p>Each node in the DAG is given an array of n integers. If it is possible to traverse from A to B then each of B's integers must be greater than each of A's respective integers.</p>

<p>For example the graph:</p>

<pre><code>A o - &gt; o C
    \
     -&gt; 
B o - &gt; o D
</code></pre>

<p>Could be represented by:</p>

<pre><code>A = [0,1]
B = [1,0]
C = [1,2]
D = [2,2]
</code></pre>

<p>I have a few questions:</p>

<ul>
<li>Has such a representation been thought up before?</li>
<li>If no, would you help me to design an algorithm that generates the arrays of integers given a DAG?</li>
</ul>

<ds.data-structures><directed-acyclic-graph>
A possibly new representation of DAGs
dan_waterworth
# A possibly new representation of DAGs

(Asked by: username_0 on 2011-04-03)

I had an idea for a way of representing DAGs, it's very easy to explain:
Each node in the DAG is given an array of n integers. If it is possible to traverse from A to B then each of B's integers must be greater than each of A's respective integers.
For example the graph:
A o - > o C
    \
     -> 
B o - > o D

Could be represented by:
A = [0,1]
B = [1,0]
C = [1,2]
D = [2,2]

I have a few questions:

Has such a representation been thought up before?
If no, would you help me to design an algorithm that generates the arrays of integers given a DAG?

**Tags:** ds.data-structures, directed-acyclic-graph

---

## 3 answers

### Answer by username_1 on 2011-04-03. Score: 15

**[Revised.]** I think that there has been a little confusion about what I was referring to in my original answer. I am revising it in order to better describe the result.

Note that your representation will only be capable of representing transitively-closed DAGs, *i.e.* partial orders; and this representation is a previously-studied one for partial orders. For instance, [a paper by Mihalis Yannakakis](http://epubs.siam.org/sima/resource/1/sjmael/v3/i3/p351_s1) shows that determining whether a partial order (equivalently, a transitively-closed digraph) has such a representation is **NP**-complete for *n* ≥ 3, but feasible if *n* ≤ 2.

---

Also, because the representation describes transitively closed DAGs, the body of research on the *Transitive Closure* problem is a reasonable place to look for related representations. [My original response](https://cstheory.stackexchange.com/revisions/215e2e49-675d-4ddc-a836-bda57afd2031/view-source) described a representation which, as it turned out, was strictly less general than the representation in terms of vectors. However, your representation has some similarities to the **tree-cover** representation of transitively closed DAGs (see [Efficient management of transitive relationships in large data and knowledge bases](http://portal.acm.org/citation.cfm?id=66950): also described briefly in [this article](http://research.microsoft.com/pubs/144985/TODSFinal.pdf)).

* Without loss of generality, if the DAG has more than one 'source' (vertex with in-degree 0), add a virtual 'root' which can reach all of the sources. The entire DAG then has a spanning tree.
* For each vertex, define an interval [ *av* , *bv* ] to each vertex *v*, in such a way that the interval at each node contains the intervals of all its descendants. (For instance, the upper bound *bv* for each *v* can be taken to be the post-fix order of the vertex in the tree; the lower bound *av* is the minimum of these post-fix values for the sub-tree.)
* To represent directed edges which are not in the tree, each node keeps a list of the intervals of the different nodes which are reachable from it. (For any given sub-tree which is reachable from a given node, it suffices to record the interval belonging to the root of that sub-tree.)

Thus, the in-bound edges of each vertex is represented by the single interval [ *av* , *bv* ] , and its outbound edges are represented by a union of disjoint intervals which strictly contain the intervals of vertices that it can reach.

Some observations:

1. The vector representation is related to the interval nesting condition by using higher dimensional "intervals". Without loss of generality, the length *n* of the array **x***v* at each vertex is even (by buffering with a final dummy co-ordinate if needed). Let *m* = *n*/2. Partition the coefficients as
   $$ \mathbf x^v \;=\; [ \;a^v\_1 \;,\; \ldots \;,\; a^v\_m \;;\; c^v\_1 \;,\; \ldots \;,\; c^v\_m \;] $$
   For each 1 ≤ *j* ≤ *m* , let $$ U\_j = \left( \max\_v \;\; a^v\_j \right) + \left( \max\_v \;\; c^v\_j \right). $$ Then, we may define for each node an *m*-fold cartesian product of intervals,
   $$ I^v \;=\; [\;a^v\_1\;,\; U\_1-c^v\_1 \;] \times \cdots \times [\;a^v\_m\;,\; U\_m-c^v\_m \;]. $$
   Two such "$m$-dimensional intervals" nest if and only if the corresponding vectors have the appropriate ordering relations. It is trivial to verify that the intervals nest only if the corresponding vectors are ordered; for the converse, we depend on none of the coefficients in the graph being larger than the corresponding bounds *Uj* .
2. It is not clear to me whether the representation by vectors and by tree-covers are efficiently interconvertible; however it is easy to show that the case *n* = 2 corresponds exactly to the representation of directed trees in terms of tree-covers (*i.e.* the two representations are efficiently and reversibly inter-convertible, essentially by the technique I described above). Thus, the dimension may in some sense correspond to how tree-like the digraph is.

> **Comments:**
> **username_2**: Niel, I don't know if you saw my answer: the key notion is the "dimension": there's a relatively simple argument that shows that the dimension of a lattice is at most its width, and indeed your example shows that this inequality can be made quite loose (2 vs n)  
> **username_1**: @Suresh: it turns out that there is possibly more than one meaning of the phrase "chain decomposition". The literature on intersections of linear orders describe those orders as "chains"; but this is different from the vertex-disjoint decomposition into "chains" in the graph which I described. But never mind; if everyone assumed that I meant the former instead of the latter, I can revise my answer correspondingly.  

---

### Answer by username_2 on 2011-04-03. Score: 8

As Niel noted, your representation is transitively closed. If we go from a digraph to its transitive closure (which is a partial order) then your representation is used to define the dimension of a partial order.

Specifically, the dimension of a partial order corresponds to the minimum number of "coordinates" you need in your representation to correctly capture the ordering relationship among elements.


---

### Answer by username_3 on 2011-04-03. Score: 6

> Has such a representation been thought up before?

For partial orders, yes. A lot of tableaux/sequent calculi for modal logics have used lists of integers to represent "possible worlds" and incorporate the relationships between worlds. It's an old technique (I think first going back to Fitting's work, I think in ["Intuitionistic logic, model theory and forcing"](http://openlibrary.org/books/OL4441316M/Intuitionistic_logic_model_theory_and_forcing) or [Proof methods for modal and intuitionistic logics](http://openlibrary.org/books/OL22333319M/Proof_methods_for_modal_and_intuitionistic_logics)).


---

