Ejemplo n.º 1
0
        public void Test_is_graph_topological_sortable_for_non_cycle_case()
        {
            var edgeList = new int[3][];

            edgeList[0] = new[] { 1, 2 };
            edgeList[1] = new[] { 2, 3 };
            edgeList[2] = new[] { 3, 4 };
            var graph           = Graph.BuildDirectedGraph(edgeList);
            var topologicalSort = new TopologicalSort(3, graph);

            Assert.True(topologicalSort.IsSortable());
        }
Ejemplo n.º 2
0
        public void Test_Topological_Sort()
        {
            var edgeList = new int[11][];
            int index    = 0;

            edgeList[index++] = new[] { 5, 11 };
            edgeList[index++] = new[] { 11, 2 };
            edgeList[index++] = new[] { 11, 9 };
            edgeList[index++] = new[] { 11, 10 };
            edgeList[index++] = new[] { 7, 11 };
            edgeList[index++] = new[] { 7, 8 };
            edgeList[index++] = new[] { 8, 9 };
            edgeList[index++] = new[] { 3, 8 };
            edgeList[index]   = new[] { 3, 10 };
            var graph           = Graph.BuildDirectedGraph(edgeList);
            var topologicalSort = new TopologicalSort(13, graph);

            Assert.True(topologicalSort.IsSortable());
        }