<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Aug 18, 2011, at 10:17 AM, Chandler Carruth wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div class="gmail_quote">On Thu, Aug 18, 2011 at 10:03 AM, Delesley Hutchins <span dir="ltr"><<a href="mailto:delesley@google.com">delesley@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
AFAICT, the RPO iterator does not do what we need.  For example,<br>
assume we have the following graph (pardon the bad ASCII graphics):<br>
<br>
   /---> (2) ----------\<br>
(1)                     --> (5)<br>
   \---> (3) ---> (4)--/<br>
<br>
I believe the RPO iterator will traverse this graph as 5-2-4-3-1,<br>
which is a standard depth-first post-order traversal.<br>
<br>
What we want is a topological traversal, which is 1-2-3-4-5; every<br>
predecessor of a node must be traversed before the node itself.<br></blockquote><div><br></div><div>What about the reverse of the RPO violates this constraint? 1-3-4-2-5 looks like it satisfies your constraint. I think Jakub is aware that we would have to reverse the order, and was just claiming that such a reversed order satisfied the constraints of a topological ordering.</div></div></blockquote><div><br></div><div>Right, the 'R' in RPO stands for 'reverse'. Sorry if that wasn't clear.</div><div><br></div><div>See the ReversePostOrderTraversal class in the PostOrderIterator.h header file.</div><div><br></div><div>Given a DAG, it is easy to see that A --> B implies A > B in the DFS post-order. Thus, A < B in the reverse post-order.</div><div><br></div><div>/jakob</div><div><br></div></div></body></html>