public void DepthFirst_Smoke_Test() { var graph = new Graph <char>(); graph.AddVertex('A'); graph.AddVertex('B'); graph.AddVertex('C'); graph.AddVertex('D'); graph.AddVertex('E'); graph.AddVertex('F'); graph.AddVertex('G'); graph.AddVertex('H'); graph.AddVertex('I'); graph.AddEdge('A', 'F'); graph.AddEdge('B', 'F'); graph.AddEdge('B', 'G'); graph.AddEdge('C', 'H'); graph.AddEdge('C', 'I'); graph.AddEdge('D', 'G'); graph.AddEdge('D', 'H'); graph.AddEdge('E', 'F'); graph.AddEdge('E', 'I'); var algo = new DepthFirst <char>(); Assert.IsTrue(algo.Find(graph, 'D')); Assert.IsFalse(algo.Find(graph, 'M')); }
public void DepthFirst_AdjacencyMatrixGraph_Smoke_Test() { var graph = new Advanced.Algorithms.DataStructures.Graph.AdjacencyMatrix.Graph <char>(); graph.AddVertex('A'); graph.AddVertex('B'); graph.AddVertex('C'); graph.AddVertex('D'); graph.AddVertex('E'); graph.AddVertex('F'); graph.AddVertex('G'); graph.AddVertex('H'); graph.AddVertex('I'); graph.AddEdge('A', 'F'); graph.AddEdge('B', 'F'); graph.AddEdge('B', 'G'); graph.AddEdge('C', 'H'); graph.AddEdge('C', 'I'); graph.AddEdge('D', 'G'); graph.AddEdge('D', 'H'); graph.AddEdge('E', 'F'); graph.AddEdge('E', 'I'); var algorithm = new DepthFirst <char>(); Assert.IsTrue(algorithm.Find(graph, 'D')); Assert.IsFalse(algorithm.Find(graph, 'M')); }
public void SearchedVertexValueIsTheFirstOne() { // Arrange var graph = new Graph <char>(); graph.AddVertex('A'); graph.AddVertex('B'); var depthFirst = new DepthFirst <char>(); // Act & Assert Assert.True(depthFirst.Find(graph.FirstVertexOrNull, 'A')); }
public void SearchedVertexValueIsNotFound() { // Arrange var graph = new Graph <char>(); graph.AddVertex('A'); graph.AddVertex('B'); graph.AddEdge('A', 'B'); var depthFirst = new DepthFirst <char>(); // Act & Assert Assert.False(depthFirst.Find(graph.FirstVertexOrNull, 'X')); }