private void RemoveCyclesFromGluedConstraints()
        {
            var feedbackSet = CycleRemoval <IntPair> .
                              GetFeedbackSetWithConstraints(new BasicGraph <IntPair>(GluedUpDownIntConstraints, this.intGraph.NodeCount), null);

            //feedbackSet contains all glued constraints making constraints cyclic
            foreach (IntPair p in feedbackSet)
            {
                GluedUpDownIntConstraints.Remove(p);
            }
        }
        void CreateGraphAndRemoveCycles()
        {
            //edges in the graph go from a smaller value to a bigger value
            graph = new BasicGraphOnEdges <IntPair>(constraints, varList.Count + boundsToInt.Count);
            //removing cycles
            var feedbackSet = CycleRemoval <IntPair> .GetFeedbackSet(graph);

            if (feedbackSet != null)
            {
                foreach (var edge in feedbackSet)
                {
                    graph.RemoveEdge(edge as IntPair);
                }
            }
        }
        //see UpDownMonotone.png
//        void MakeUpDownRelationsMonotone(int[] yLayers) {
//            BasicGraph<IntPair> upDownGraph = new BasicGraph<IntPair>(from c in this.verticalInts select new IntPair(c.First,c.Second));
//            List<Tuple<int, int>> upDownToRemove = new List<Tuple<int, int>>();
//            foreach (IEnumerable<int> componentNodes in ConnectedComponentCalculator<IntPair>.GetComponents(GraphOfLeftRightRelations())) {
//                ResolveConflictsUboveComponent(upDownGraph, componentNodes, upDownToRemove, yLayers);
//                ResolveConflictsBelowComponent(upDownGraph, componentNodes, upDownToRemove, yLayers);
//            }
//
//            foreach (var v in upDownToRemove)
//                this.verticalInts.Remove(v);
//        }
        //makes left-right relations to be between neighb blocks and removes cycles in these relations
        void LiftLeftRightRelationsToNeibBlocks()
        {
            LeftRighInts = new Set <Tuple <int, int> >(from p in leftRightConstraints
                                                       let ip =
                                                           new Tuple <int, int>(NodeIndex(p.Item1), NodeIndex(p.Item2))
                                                           where ip.Item1 != -1 && ip.Item2 != -1
                                                           let ipb =
                                                               new Tuple <int, int>(NodeToBlockRootSoft(ip.Item1),
                                                                                    NodeToBlockRootSoft(ip.Item2))
                                                               where ipb.Item1 != ipb.Item2
                                                               select ipb);
            IEnumerable <IEdge> feedbackSet =
                CycleRemoval <IntPair> .GetFeedbackSet(
                    new BasicGraph <IntPair>(from p in LeftRighInts select new IntPair(p.Item1, p.Item2)));

            foreach (IntPair ip in feedbackSet)
            {
                LeftRighInts.Remove(new Tuple <int, int>(ip.First, ip.Second));
            }
        }
 private IEnumerable <IEdge> GetFeedbackSet()
 {
     this.gluedIntGraph = CreateGluedGraph();
     return(UnglueIntPairs(CycleRemoval <IntPair> .GetFeedbackSetWithConstraints(gluedIntGraph, this.GluedUpDownIntConstraints)));//avoiding lazy evaluation
 }