예제 #1
0
        // Alternative way of calculating the boolean width of a decomposition by counting the number of maximal independent sets in bipartite graphs,
        // constructed for each cut of the decomposition
        private long CalculateBooleanWidthBiPartite()
        {
            BitSet left = new BitSet(0, Graph.Size);
            BitSet right = Graph.Vertices;
            long max = int.MinValue;

            foreach (int v in Sequence)
            {
                left.Add(v);
                right.Remove(v);
                // Construct the bipartite graph
                BipartiteGraph bg = new BipartiteGraph(Graph, left, right);

                // Count the number of maximal independent sets in this bipartite graph
                max = Math.Max(max, CC_MIS.Compute(bg));
            }
            return max;
        }
예제 #2
0
        // Implementation of Algorithm 13 of the PhD thesis by Sadia Sharmin
        // The LeastCutValue selection method picks the next vertex based on a greedy choice, namely what is the vertex that will have the least
        // influence on the boolean dimension at this point.
        // While this generally gives great results, the runtime is very high because we construct multiple bipartite graphs during every iteration.
        private static int LeastCutValue(Graph graph, BitSet left, BitSet right)
        {
            // Minimum boolean dimension that we can have for our next cut
            long minBoolDim = long.MaxValue;

            // Vertex that we will choose
            int chosen = -1;

            // Foreach candidate vertex we construct a bipartite graph and count the number of minimal independent sets in this bipartite graph
             //This number is equal to the boolean-dimension at this cut
            foreach (int v in right)
            {
                // Construct the bipartite graph
                BipartiteGraph bg = new BipartiteGraph(graph, left + v, right - v);

                // Count the number of MIS in the bipartite graph
                long boolDim = CC_MIS.Compute(bg);

                // Possibly update the minimum value found so far
                if (boolDim < minBoolDim)
                {
                    chosen = v;
                    minBoolDim = boolDim;
                }
            }

            return chosen;
        }