public void DfsTopologicalSort_WhenAcyclicGraph_ThenTopologicalOrder()
        {
            // given
            DirectedSimpleGraph <int, object, object> graph = new DirectedSimpleGraph <int, object, object>(
                Enumerable.Range(0, 6).ToArray());

            graph.AddEdgeBetween(graph[0], graph[2]);
            graph.AddEdgeBetween(graph[0], graph[4]);
            graph.AddEdgeBetween(graph[1], graph[0]);
            graph.AddEdgeBetween(graph[1], graph[4]);
            graph.AddEdgeBetween(graph[3], graph[1]);
            graph.AddEdgeBetween(graph[3], graph[0]);
            graph.AddEdgeBetween(graph[3], graph[2]);
            graph.AddEdgeBetween(graph[5], graph[1]);
            graph.AddEdgeBetween(graph[5], graph[2]);
            graph.AddEdgeBetween(graph[5], graph[4]);

            var expecteds = new Vertex <int>[][] {
                new Vertex <int>[] { graph[3], graph[5], graph[1], graph[0], graph[2], graph[4] },
                new Vertex <int>[] { graph[5], graph[3], graph[1], graph[0], graph[2], graph[4] },
                new Vertex <int>[] { graph[3], graph[5], graph[1], graph[0], graph[4], graph[2] },
                new Vertex <int>[] { graph[5], graph[3], graph[1], graph[0], graph[4], graph[2] }
            };
            // when
            IEnumerable <Vertex <int> > result = TopologicalSorting.DfsTopologicalSort(graph);

            // then
            expecteds.Should().ContainEquivalentOf(result.ToArray());
        }
        public void DfsTopologicalSort_WhenCyclicGraph_ThenDirectedCyclicGraphException()
        {
            // given
            DirectedSimpleGraph <int, object, object> graph = new DirectedSimpleGraph <int, object, object>(
                Enumerable.Range(0, 6).ToArray());

            graph.AddEdgeBetween(graph[0], graph[2]);
            graph.AddEdgeBetween(graph[0], graph[4]);
            graph.AddEdgeBetween(graph[1], graph[0]);
            graph.AddEdgeBetween(graph[1], graph[4]);
            graph.AddEdgeBetween(graph[2], graph[1]);
            graph.AddEdgeBetween(graph[3], graph[1]);
            graph.AddEdgeBetween(graph[3], graph[0]);
            graph.AddEdgeBetween(graph[3], graph[2]);
            graph.AddEdgeBetween(graph[5], graph[1]);
            graph.AddEdgeBetween(graph[5], graph[2]);
            graph.AddEdgeBetween(graph[5], graph[4]);
            // when
            Action action = () => TopologicalSorting.DfsTopologicalSort(graph);

            // then
            action.Should().Throw <DirectedCyclicGraphException>();
        }