Beispiel #1
0
        public static string CheckIfNodesPresentInWis(int[] nodesToCheck)
        {
            var maxWeightCalculator = new MaxWeightIndependentSetPathGraph();
            var maximumSet          = maxWeightCalculator.GetMaxWeightIndependentSet(ParsePathGraphFromWeb());
            var result = new StringBuilder(nodesToCheck.Length);

            foreach (var node in nodesToCheck)
            {
                result.Append(maximumSet.Contains(node) ? '1' : '0');
            }

            return(result.ToString());
        }
        public void SmallPathGraph()
        {
            var graph = new[] { 1, 4, 5, 4 };
            var nodesShouldBeIncluded    = new [] { 2, 4 };
            var nodesShouldNotBeIncluded = new[] { 1, 3 };
            var maxSetFinder             = new MaxWeightIndependentSetPathGraph();
            var result = maxSetFinder.GetMaxWeightIndependentSet(graph);

            for (int i = 0; i < nodesShouldBeIncluded.Length; i++)
            {
                Assert.IsTrue(result.Contains(nodesShouldBeIncluded[i]));
                Assert.IsFalse(result.Contains(nodesShouldNotBeIncluded[i]));
            }
        }