public static ISet <Edge <BasicBlock> > FindReverseEdges(ControlFlowGraph.Graph g) { ISet <Edge <BasicBlock> > res = SetFactory.GetEdgesSet();//new SortedSet<Edge <BasicBlock>>(); Dictionary <Edge <BasicBlock>, EdgeType> ClassifiedEdges = EdgeClassification.EdgeClassification.ClassifyEdge(g); Dictionary <int, int> Dominators = ImmediateDominator.FindImmediateDominator(g); var RetreatingEdges = ClassifiedEdges.Where(x => x.Value == EdgeType.Retreating); foreach (var edg in RetreatingEdges) { var edge = edg.Key; int key = edge.Source.BlockId; int value = edge.Target.BlockId; bool isReverse = false; while (Dominators.ContainsKey(key) && Dominators[key] != key && !isReverse) { key = Dominators[key]; isReverse = (key == value); } if (isReverse) { res.Add(edge); } } return(res); }