コード例 #1
0
        public Dictionary <RedBlackEnum, List <int> > GetRedBlackDictionary(LinearProblemProperties input)
        {
            var graph = input.ConstrGraph;

            var nodeDictionary = BreadthFirstSearch.GetBoolLevelBFS(graph, 0);

            if (nodeDictionary.Count < input.Count)
            {
                for (int i = 0; i < input.Count; i++)
                {
                    if (!nodeDictionary.ContainsKey(i))
                    {
                        var dict = BreadthFirstSearch.GetBoolLevelBFS(graph, i);
                        foreach (var element in dict)
                        {
                            nodeDictionary.Add(element.Key, element.Value);
                        }

                        if (nodeDictionary.Count == input.Count)
                        {
                            break;
                        }
                    }
                }
            }

            var redBlackDictionary = GetRedBlackDictionary(nodeDictionary);

            return(redBlackDictionary);
        }