Partial LSE: handle all kinds of infinite loops. A subgraph could also have an infinite loop. Test: 826-inifinite-loop Bug: 196246395 Change-Id: Ifd1e1ae0f42dfe2cc156386fc166101c20748fc9