<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Oct 18, 2013 at 8:16 PM, Rui Ueyama <span dir="ltr"><<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
  OK, so O(n^3) is probably not good even for debugging.</blockquote><div><br></div><div>Where is the O(n^3)? I see a double loop that does O(n^2) work, but I don't see anything O(n^3).</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'll rewrite it with the same algorithm as topological sort, as topological sort can detect a cycle in a graph. That is much cheaper than this naive algorithm.<br></blockquote><div><br></div><div>If the problem is the fully general problem "given n elements, and a relation <, determine whether < is transitive", I don't think that topological sorting is going to be of any help here, since it takes time O(#vertices + #edges).</div>
<div><br></div><div>Another way to think about it is that when topologically sorting, for each node you have to iterate over all its children. Since you can't assume anything about the ordering (because that's what you're trying to verify!), you have to do a linear scan of *all* the other nodes in order to find the children.</div>
<div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
<a href="http://llvm-reviews.chandlerc.com/D1980" target="_blank">http://llvm-reviews.chandlerc.com/D1980</a><br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>