/// <inheritdoc/> public override bool Add(int n, int m) { if (!matrix.Get1(n, m)) { return(false); } // fix the mapping matrix.MarkRow(n, -(n + 1)); matrix.Set1(n, m); // attempt to refine the mapping if (Refine(n)) { size = size + 1; m1[n] = m; m2[m] = n; return(true); } else { // mapping became invalid - unfix mapping matrix.ResetRows(n, -(n + 1)); return(false); } }
public void AccessAndModify() { CompatibilityMatrix m = new CompatibilityMatrix(5, 5); Assert.IsFalse(m.Get1(0, 1)); Assert.IsFalse(m.Get1(0, 4)); Assert.IsFalse(m.Get1(1, 0)); Assert.IsFalse(m.Get1(1, 3)); m.Set1(0, 1); m.Set1(0, 4); m.Set1(1, 0); m.Set1(1, 3); Assert.IsTrue(m.Get1(0, 1)); Assert.IsTrue(m.Get1(0, 4)); Assert.IsTrue(m.Get1(1, 0)); Assert.IsTrue(m.Get1(1, 3)); }
public void Mark() { CompatibilityMatrix m = new CompatibilityMatrix(5, 5); m.Set1(0, 1); m.Set1(0, 2); m.Set1(0, 4); m.Set1(1, 0); m.Set1(1, 3); Assert.IsTrue(m.Get1(0, 1)); Assert.IsTrue(m.Get1(0, 4)); m.Mark(0, 1, -1); m.Mark(0, 4, -4); m.Mark(1, 3, -6); Assert.IsFalse(m.Get1(0, 1)); Assert.IsFalse(m.Get1(0, 4)); Assert.IsFalse(m.Get1(1, 3)); m.ResetRows(0, -1); Assert.IsTrue(m.Get1(0, 1)); Assert.IsFalse(m.Get1(0, 4)); Assert.IsFalse(m.Get1(1, 3)); m.ResetRows(0, -4); Assert.IsTrue(m.Get1(0, 1)); Assert.IsTrue(m.Get1(0, 4)); Assert.IsFalse(m.Get1(1, 3)); m.ResetRows(0, -6); Assert.IsTrue(m.Get1(0, 1)); Assert.IsTrue(m.Get1(0, 4)); Assert.IsTrue(m.Get1(1, 3)); }