コード例 #1
0
        public void DepthFirstSearch_ShouldThrowArgumentException_WhenInitialVertexDoesNotExistInGraph(GraphBase <int> graph, int initialVertex)
        {
            var dfsAlgorithm = new DepthFirstSearch <GraphBase <int>, int>();

            Assert.Throws <ArgumentException>(() =>
            {
                dfsAlgorithm.Execute(graph, initialVertex, vertex => { });
            });
        }
コード例 #2
0
        public void DepthFirstSearch_ShouldThrowArgumentNullException_WhenInputParametersAreInvalid(GraphBase <int> graph, int initialVertex, Action <int> action)
        {
            var dfsAlgorithm = new DepthFirstSearch <GraphBase <int>, int>();

            Assert.Throws <ArgumentNullException>(() =>
            {
                dfsAlgorithm.Execute(graph, initialVertex, action);
            });
        }
コード例 #3
0
        public void DepthFirstSearch_ShouldPerformSpecifiedAction_ForAllVerticesInConnectedComponent(GraphBase <int> graph, int initialVertex, IEnumerable <int> expectedVisitedVertices)
        {
            var dfsAlgorithm = new DepthFirstSearch <GraphBase <int>, int>();
            var result       = new List <int>();

            dfsAlgorithm.Execute(graph, initialVertex, vertex =>
            {
                result.Add(vertex);
            });

            Assert.Equal(expectedVisitedVertices, result);
        }