コード例 #1
0
ファイル: GraphTests.cs プロジェクト: ilyichumakov/FlowTask
        public void FordFalkerson2Test()
        {
            int[][] matrixx = new int[5][];

            matrixx[0] = new int[] { 0, 1, 3, 0, 0 };
            matrixx[1] = new int[] { 1, 0, 0, 2, 0 };
            matrixx[2] = new int[] { 3, 0, 0, 2, 7 };
            matrixx[3] = new int[] { 0, 2, 2, 0, 4 };
            matrixx[4] = new int[] { 0, 0, 7, 4, 0 };

            FlowAlgorythms a    = new FlowAlgorythms(new Graph(matrixx));
            int            flow = 3;

            Assert.AreEqual(flow, a.FordFalkerson(1, 2)); // numeration from 1
        }
コード例 #2
0
ファイル: GraphTests.cs プロジェクト: ilyichumakov/FlowTask
        public void CriticalPathTest()
        {
            int[][] matrixx = new int[5][];

            matrixx[0] = new int[] { 0, 4, 5, Int32.MaxValue, Int32.MaxValue };
            matrixx[1] = new int[] { Int32.MaxValue, 0, 3, Int32.MaxValue, Int32.MaxValue };
            matrixx[2] = new int[] { Int32.MaxValue, Int32.MaxValue, 0, 2, 4 };
            matrixx[3] = new int[] { Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, 0, 1 };
            matrixx[4] = new int[] { Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, Int32.MaxValue, 0 };

            FlowAlgorythms a = new FlowAlgorythms(new Graph(matrixx));

            int[] path         = new int[] { 1, 2, 3, 5 };
            int[] criticalTime = new int[] { 0, 4, 7, 9, 11 };

            Tuple <int[], int[]> res = a.CriticalPath();

            Assert.AreEqual(path, res.Item1); // numeration from 1
            Assert.AreEqual(criticalTime, res.Item2);
        }