Partial LSE: handle all kinds of infinite loops.

A subgraph could also have an infinite loop.

Test: 826-inifinite-loop
Bug: 196246395
Merged-In: Ifd1e1ae0f42dfe2cc156386fc166101c20748fc9
(cherry picked from commit 96dadefd24331f6808cb287048269ba772423c33)
Change-Id: I410ec26aefbc42629ba7dbe5a19a87399cefe396
5 files changed