public void IsPotMaxClique_NotPotMaxClique()
        {
            string         testFile1 = "..\\..\\Test Data\\test1.gr";
            Graph          g         = new Graph(testFile1);
            ImmutableGraph graph     = new ImmutableGraph(g);

            BitSet j = new BitSet(6, new int[] { 0 });
            BitSet k = new BitSet(6, new int[] { 0, 1 });
            BitSet l = new BitSet(6, new int[] { 0, 4 });
            BitSet m = new BitSet(6, new int[] { 0, 5 });
            BitSet n = new BitSet(6, new int[] { 1, 5 });
            BitSet o = new BitSet(6, new int[] { 2, 5 });
            BitSet p = new BitSet(6, new int[] { 3, 5 });
            BitSet q = new BitSet(6, new int[] { 1, 2 });
            BitSet r = new BitSet(6, new int[] { 0, 3 });

            Assert.IsFalse(graph.IsPotMaxClique(j));
            Assert.IsFalse(graph.IsPotMaxClique(k));
            Assert.IsFalse(graph.IsPotMaxClique(l));
            Assert.IsFalse(graph.IsPotMaxClique(m));
            Assert.IsFalse(graph.IsPotMaxClique(n));
            Assert.IsFalse(graph.IsPotMaxClique(o));
            Assert.IsFalse(graph.IsPotMaxClique(p));
            Assert.IsFalse(graph.IsPotMaxClique(q));
            Assert.IsFalse(graph.IsPotMaxClique(r));
        }
Пример #2
0
        /// <summary>
        /// Adds an empty basic block to this flow-graph builder.
        /// </summary>
        /// <param name="name">The (preferred) name of the basic block's tag.</param>
        /// <returns>An empty basic block builder.</returns>
        public BasicBlockBuilder AddBasicBlock(string name)
        {
            var newBlock = ImmutableGraph.AddBasicBlock(name);

            ImmutableGraph = newBlock.Graph;
            return(GetBasicBlock(newBlock.Tag));
        }
        /// <summary>
        /// asserts that the treewidth that the algorithm finds is the graph's actual treewidth
        /// </summary>
        /// <param name="g">the graph to test</param>
        /// <param name="treewidth">the graph's actual tree width</param>
        private void AssertCorrectTreewidth(Graph g, int treewidth)
        {
            Treewidth.completeHeuristically                   = false;
            Treewidth.moreThan2ComponentsOptimization         = true;
            Treewidth.keepOnlyPTDsWithLargerInletIfSameOutlet = true;
            Treewidth.testOutletIsCliqueMinor                 = true;
            PTD.testIfAddingOneVertexToBagFormsPMC            = false;
            ImmutableGraph h = new ImmutableGraph(g);   // copy for check if treewidth is correct

            Assert.AreEqual(treewidth, Treewidth.TreeWidth(g, out PTD output));

            output.AssertValidTreeDecomposition(h);
        }
        public void IsPotMaxClique_PotMaxClique()
        {
            string         testFile1 = "..\\..\\Test Data\\test1.gr";
            Graph          g         = new Graph(testFile1);
            ImmutableGraph graph     = new ImmutableGraph(g);

            BitSet a = new BitSet(6, new int[] { 0, 1, 2 });
            BitSet b = new BitSet(6, new int[] { 1, 2, 3, 4 });
            BitSet c = new BitSet(6, new int[] { 4, 5 });

            Assert.IsTrue(graph.IsPotMaxClique(a));
            Assert.IsTrue(graph.IsPotMaxClique(b));
            Assert.IsTrue(graph.IsPotMaxClique(c));
        }
Пример #5
0
 /// <summary>
 /// Applies a sequence of intraprocedural optimizations to this flow graph.
 /// </summary>
 /// <param name="optimizations">
 /// The transforms to apply.
 /// </param>
 public void Transform(IEnumerable <IntraproceduralOptimization> optimizations)
 {
     ImmutableGraph = ImmutableGraph.Transform(optimizations);
 }
Пример #6
0
 /// <summary>
 /// Applies a sequence of intraprocedural optimizations to this flow graph.
 /// </summary>
 /// <param name="optimizations">
 /// The transforms to apply.
 /// </param>
 public void Transform(params IntraproceduralOptimization[] optimizations)
 {
     ImmutableGraph = ImmutableGraph.Transform(optimizations);
 }
Пример #7
0
 /// <summary>
 /// Removes the definitions for a set of instructions
 /// from this flow graph.
 /// </summary>
 /// <param name="instructionsToRemove">
 /// A set of values whose definitions are to be eliminated
 /// from the flow graph. These values may only refer to
 /// instructions.
 /// </param>
 /// <remark>
 /// This method incurs less overhead than RemoveDefinitions but
 /// only works for instruction definitions, not for basic block
 /// parameter definitions.
 /// </remark>
 public void RemoveInstructionDefinitions(IEnumerable <ValueTag> instructionsToRemove)
 {
     ImmutableGraph = ImmutableGraph.RemoveInstructionDefinitions(instructionsToRemove);
 }
Пример #8
0
 /// <summary>
 /// Applies an intraprocedural optimization to this flow graph.
 /// </summary>
 /// <param name="optimization">
 /// The transform to apply.
 /// </param>
 public void Transform(IntraproceduralOptimization optimization)
 {
     ImmutableGraph = ImmutableGraph.Transform(optimization);
 }
Пример #9
0
 /// <summary>
 /// Registers a flow graph analysis with this graph.
 /// </summary>
 /// <param name="analysis">The analysis to register.</param>
 /// <typeparam name="T">
 /// The type of result produced by the analysis.
 /// </typeparam>
 public void AddAnalysis <T>(IFlowGraphAnalysis <T> analysis)
 {
     ImmutableGraph = ImmutableGraph.WithAnalysis <T>(analysis);
 }
Пример #10
0
 /// <summary>
 /// Removes the definitions for a set of values
 /// from this flow graph.
 /// </summary>
 /// <param name="valuesToRemove">
 /// A set of values whose definitions are to be eliminated
 /// from the flow graph. These values can refer to instructions
 /// and basic block parameters.
 /// </param>
 public void RemoveDefinitions(IEnumerable <ValueTag> valuesToRemove)
 {
     ImmutableGraph = ImmutableGraph.RemoveDefinitions(valuesToRemove);
 }
Пример #11
0
 /// <summary>
 /// Checks if this control-flow graph contains a basic block parameter
 /// with a particular tag.
 /// </summary>
 /// <param name="tag">The parameter's tag.</param>
 /// <returns>
 /// <c>true</c> if this control-flow graph contains a basic block parameter
 /// with the given tag; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsBlockParameter(ValueTag tag)
 {
     return(ImmutableGraph.ContainsBlockParameter(tag));
 }
Пример #12
0
 /// <summary>
 /// Gets the type of a value in this graph.
 /// </summary>
 /// <param name="tag">The value's tag.</param>
 /// <returns>The value's type.</returns>
 public IType GetValueType(ValueTag tag)
 {
     return(ImmutableGraph.GetValueType(tag));
 }
Пример #13
0
 /// <summary>
 /// Checks if this control-flow graph contains a basic block
 /// with a particular tag.
 /// </summary>
 /// <param name="tag">The basic block's tag.</param>
 /// <returns>
 /// <c>true</c> if this control-flow graph contains a basic block
 /// with the given tag; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsBasicBlock(BasicBlockTag tag)
 {
     return(ImmutableGraph.ContainsBasicBlock(tag));
 }
Пример #14
0
 /// <summary>
 /// Gets the analysis, registered with this control-flow graph,
 /// that produced a particular type of result.
 /// </summary>
 /// <typeparam name="T">
 /// The type of analysis result that is sought.
 /// </typeparam>
 /// <returns>
 /// An analysis.
 /// </returns>
 public IFlowGraphAnalysis <T> GetAnalysisFor <T>()
 {
     return(ImmutableGraph.GetAnalysisFor <T>());
 }
Пример #15
0
 /// <summary>
 /// Tells if this flow graph has an analysis that produces
 /// a particular type of result.
 /// </summary>
 /// <typeparam name="T">
 /// The type of analysis result that is sought.
 /// </typeparam>
 /// <returns>
 /// <c>true</c> if a registered analysis produces a result of type <c>T</c>;
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool HasAnalysisFor <T>()
 {
     return(ImmutableGraph.HasAnalysisFor <T>());
 }
Пример #16
0
 /// <summary>
 /// Tries to get an analysis result of a particular type.
 /// </summary>
 /// <param name="result">
 /// The analysis result, if one can be fetched or computed.
 /// </param>
 /// <typeparam name="T">
 /// The type of analysis result to fetch or compute.
 /// </typeparam>
 /// <returns>
 /// <c>true</c> if there is an analyzer to compute the result;
 /// otherwise, <c>false</c>.
 /// </returns>
 public bool TryGetAnalysisResult <T>(out T result)
 {
     return(ImmutableGraph.TryGetAnalysisResult <T>(out result));
 }
Пример #17
0
 /// <summary>
 /// Gets an analysis result based on its type.
 /// </summary>
 /// <typeparam name="T">
 /// The type of analysis result to fetch or compute.
 /// </typeparam>
 /// <returns>
 /// An analysis result.
 /// </returns>
 public T GetAnalysisResult <T>()
 {
     return(ImmutableGraph.GetAnalysisResult <T>());
 }
Пример #18
0
 /// <summary>
 /// Checks if this control-flow graph contains an instruction
 /// with a particular tag.
 /// </summary>
 /// <param name="tag">The instruction's tag.</param>
 /// <returns>
 /// <c>true</c> if this control-flow graph contains an instruction
 /// with the given tag; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsInstruction(ValueTag tag)
 {
     return(ImmutableGraph.ContainsInstruction(tag));
 }
Пример #19
0
 /// <summary>
 /// Removes the basic block with a particular tag from this
 /// control-flow graph.
 /// </summary>
 /// <param name="tag">The basic block's tag.</param>
 public void RemoveBasicBlock(BasicBlockTag tag)
 {
     ImmutableGraph = ImmutableGraph.RemoveBasicBlock(tag);
 }
Пример #20
0
 /// <summary>
 /// Checks if this control-flow graph contains an instruction
 /// or basic block parameter with a particular tag.
 /// </summary>
 /// <param name="tag">The value's tag.</param>
 /// <returns>
 /// <c>true</c> if this control-flow graph contains a value
 /// with the given tag; otherwise, <c>false</c>.
 /// </returns>
 public bool ContainsValue(ValueTag tag)
 {
     return(ImmutableGraph.ContainsValue(tag));
 }
Пример #21
0
 /// <summary>
 /// Removes a particular instruction from this control-flow graph.
 /// Returns a new control-flow graph that does not contain the
 /// instruction.
 /// </summary>
 /// <param name="instructionTag">The tag of the instruction to remove.</param>
 /// <returns>
 /// A control-flow graph that no longer contains the instruction.
 /// </returns>
 public void RemoveInstruction(ValueTag instructionTag)
 {
     ImmutableGraph = ImmutableGraph.RemoveInstruction(instructionTag);
 }
Пример #22
0
 /// <summary>
 /// Gets basic block that defines a value with a
 /// particular tag.
 /// </summary>
 /// <param name="tag">The tag of the value to look for.</param>
 /// <returns>The basic block that defines the value.</returns>
 public BasicBlockBuilder GetValueParent(ValueTag tag)
 {
     return(GetBasicBlock(ImmutableGraph.GetValueParent(tag).Tag));
 }
Пример #23
0
 /// <summary>
 /// Replaces all uses of values with other values.
 /// The values to replace are encoded as keys in a
 /// dictionary and the values to replace them with as
 /// values in that same dictionary.
 /// </summary>
 /// <param name="replacementMap">
 /// A mapping of values to replacement values.
 /// </param>
 public void ReplaceUses(
     IReadOnlyDictionary <ValueTag, ValueTag> replacementMap)
 {
     ImmutableGraph = ImmutableGraph.ReplaceUses(replacementMap);
 }