def checkInstructionGraphCycles(instructions):
    import networkx as nx

    g = nx.DiGraph()

    for i in instructions:
        g.add_node(i)

        for ix in range(i.flowsToCount()):
            flowsTo = i.flowsTo(ix)
            if flowsTo in instructions:
                g.add_edge(i, flowsTo)

    cycles = nx.simple_cycles(g)

    for c in cycles:
        if not checkCycleHasEntrypoint(c):
            print "************************************"
            print "No entrypoint in the following cycle: "
            for i in c:
                print i
                print "children:"
                for sub in i.children():
                    print "\t", repr(sub)
            print "************************************"
        else:
            print "************************************"
            print "cycle with ", len(c), " is OK"
            for i in c:
                if i.getTypedJumpTarget():
                    print "*** ",
                else:
                    print "    ",
                print repr(i)
            print "************************************"
dataset/ETHPy150Open ufora/ufora/ufora/FORA/Interpreter/InstructionGraph.py/checkInstructionGraphCycles/original