public void Add() { int[][] g1 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2 } }; int[][] g2 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4 } }; AbstractVFState state = Create(g1, g2); Assert.IsTrue(state.Add(0, 1)); Assert.AreEqual(1, state.size); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, UNMAPPED, UNMAPPED, UNMAPPED }, state.m1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, 0, UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED }, state.m2)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 0, 1, 0, 0 }, state.t1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 0, 1, 0, 0, 0 }, state.t2)); Assert.IsTrue(state.Add(1, 2)); Assert.AreEqual(2, state.size); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 2, UNMAPPED, UNMAPPED }, state.m1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, 0, 1, UNMAPPED, UNMAPPED, UNMAPPED }, state.m2)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 2, 1, 2, 0 }, state.t1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 2, 1, 2, 0, 0 }, state.t2)); }
public void NextMNonTerminal() { AbstractVFState state = Create(5, 10); state.size = 2; state.m2[0] = 1; state.m2[1] = 0; Assert.AreEqual(2, state.NextM(0, -1)); }
public void NextMAt0() { AbstractVFState state = Create(5, 10); Assert.AreEqual(0, state.NextM(0, -1)); Assert.AreEqual(1, state.NextM(0, 0)); Assert.AreEqual(2, state.NextM(0, 1)); Assert.AreEqual(3, state.NextM(0, 2)); }
public void NextNTerminal() { AbstractVFState state = Create(5, 10); state.size = 2; state.m1[0] = 1; state.m1[1] = 0; state.t1[4] = 1; // <- first terminal Assert.AreEqual(4, state.NextN(-1)); }
public void NextMTerminal() { AbstractVFState state = Create(5, 10); state.size = 2; state.m2[0] = 1; state.m2[1] = 0; state.t1[1] = 1; // query vertex is in terminal set state.t2[4] = 1; // <- first terminal (not kept returned for now - allow disconnected) Assert.AreEqual(4, state.NextM(1, -1)); }
public void Accessors() { int[][] g1 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2 } }; int[][] g2 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4 } }; AbstractVFState state = Create(g1, g2); Assert.AreEqual(g1.Length, state.NMax()); Assert.AreEqual(g2.Length, state.MMax()); Assert.AreEqual(0, state.Count); state.size = 2; Assert.AreEqual(2, state.Count); }
public void CopyMapping() { int[][] g1 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2 } }; int[][] g2 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4 } }; AbstractVFState state = Create(g1, g2); state.m1[0] = 1; state.m1[1] = 2; state.m1[2] = 5; state.m1[3] = 6; Assert.IsTrue(Compares.AreDeepEqual(state.m1, state.Mapping())); Assert.AreNotSame(state.m1, state.Mapping()); }
public void NextNAt0() { AbstractVFState state = Create(5, 10); Assert.AreEqual(0, state.NextN(-1)); }
public void Remove() { int[][] g1 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2 } }; int[][] g2 = new int[][] { new[] { 1 }, new[] { 0, 2 }, new[] { 1, 3 }, new[] { 2, 4 }, new[] { 3, 5 }, new[] { 4 } }; AbstractVFState state = Create(g1, g2); state.size = 2; // see Add() state.m1[0] = 1; state.m1[1] = 2; state.m2[1] = 0; state.m2[2] = 1; state.t1[0] = 2; state.t1[1] = 1; state.t1[2] = 2; state.t2[0] = 1; state.t2[1] = 2; state.t2[2] = 1; state.t2[3] = 2; Assert.AreEqual(2, state.size); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 2, UNMAPPED, UNMAPPED }, state.m1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, 0, 1, UNMAPPED, UNMAPPED, UNMAPPED }, state.m2)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 2, 1, 2, 0 }, state.t1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 2, 1, 2, 0, 0 }, state.t2)); state.Remove(1, 2); Assert.AreEqual(1, state.size); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, UNMAPPED, UNMAPPED, UNMAPPED }, state.m1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, 0, UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED }, state.m2)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 0, 1, 0, 0 }, state.t1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 1, 0, 1, 0, 0, 0 }, state.t2)); state.Remove(0, 1); Assert.AreEqual(0, state.size); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED }, state.m1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED, UNMAPPED }, state.m2)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 0, 0, 0, 0 }, state.t1)); Assert.IsTrue(Compares.AreDeepEqual( new int[] { 0, 0, 0, 0, 0, 0 }, state.t2)); }