public void IsConnected_ReturnsExpectedResult(int p, int q, bool expectedResult) { //7-9 6-9 2-0 5-8 7-4 6-1 0-5 4-3 2-4 _quickFind.Union(p, q); var actualResult = _quickFind.IsConnected(p, q); Assert.Equal(expectedResult, actualResult); }
public void IsConnected_NodesAreConnected_ReturnsTrue() { QuickFind quickFind = new QuickFind(5); quickFind.Union(1, 2); Assert.IsTrue(quickFind.IsConnected(1, 2)); }
public void IsConnected_NodesAreNotConnected_ReturnsFalse() { QuickFind quickFind = new QuickFind(5); quickFind.Union(1, 2); Assert.IsFalse(quickFind.IsConnected(2, 3)); }
public void IsConnected_MultipleUnions_ReturnsTrue() { QuickFind quickFind = new QuickFind(5); quickFind.Union(1, 2); quickFind.Union(2, 3); Assert.IsTrue(quickFind.IsConnected(1, 3)); }
public void IsConnected_UnionOfConnectedNodes_ReturnsTrue() { QuickFind quickFind = new QuickFind(5); quickFind.Union(1, 2); quickFind.Union(4, 5); quickFind.Union(1, 4); Assert.IsTrue(quickFind.IsConnected(2, 4)); }
public void test_union_find() { var uf = new QuickFind(10); uf.Union(1, 3); uf.Union(2, 3); uf.Union(5, 6); uf.Union(4, 5); Assert.True(uf.IsConnected(1, 3)); Assert.True(uf.IsConnected(2, 3)); Assert.True(uf.IsConnected(1, 2)); Assert.True(uf.IsConnected(4, 5)); Assert.True(uf.IsConnected(4, 6)); Assert.False(uf.IsConnected(1, 6)); Assert.False(uf.IsConnected(3, 4)); this.logger.WriteLine("Connected: {1, 2, 3}"); }