Ejemplo n.º 1
0
        /// <summary>
        /// Internal constructor.
        /// </summary>
        /// <param name="graph">adjacency list graph representation</param>
        /// <param name="matching">the matching of the graph</param>
        /// <param name="subset">subset a subset of vertices</param>
        private EdmondsMaximumMatching(int[][] graph, Matching matching, BitArray subset)
        {
            this.graph    = graph;
            this.matching = matching;
            this.subset   = subset;

            this.even = new int[graph.Length];
            this.odd  = new int[graph.Length];

            this.queue = new List <int>();   // LinkedList
            this.dsf   = new DisjointSetForest(graph.Length);

            // tmp storage of paths in the algorithm
            path       = new int[graph.Length];
            vAncestors = new BitArray(graph.Length);
            wAncestors = new BitArray(graph.Length);

            // continuously augment while we find new paths
            while (ExistAugmentingPath())
            {
                ;
            }
        }
Ejemplo n.º 2
0
 void AssertMatch(Matching m, int u, int v)
 {
     Assert.IsTrue(m.Matched(u));
     Assert.IsTrue(m.Matched(v));
     Assert.AreEqual(v, m.Other(u));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Attempt to maximise the provided matching over a subset of vertices in a
 /// graph.
 /// </summary>
 /// <param name="matching">the independent edge set to maximise</param>
 /// <param name="graph">adjacency list graph representation</param>
 /// <param name="subset">subset of vertices</param>
 /// <returns>the matching</returns>
 public static Matching Maxamise(Matching matching, int[][] graph, BitArray subset)
 {
     new EdmondsMaximumMatching(graph, matching, subset);
     return(matching);
 }