Beispiel #1
0
        public static void test()
        {
            {
                string input = @"
14
15
1  5
2  4
2  3
3  9
4  5
5  7
5  6
6  8
7 8
8 2
8 9
9 11
9 10
10 11
12 13
";

                var graph = new Digraph <int>(input, (string s) => System.Int32.Parse(s));
                var sort  = Postorder.Sort(graph, new List <int>()
                {
                    1
                });
                foreach (var n in sort)
                {
                    System.Console.Error.WriteLine(n);
                }
            }
            {
                string input = @"
6
5
1  2
2  4
2  5
1  3
3  6
";

                var graph = new Digraph <int>(input, (string s) => System.Int32.Parse(s));
                var sort  = Postorder.Sort(graph, new List <int>()
                {
                    1
                });
                foreach (var n in sort)
                {
                    System.Console.Error.WriteLine(n);
                }
            }
        }
Beispiel #2
0
        public static void test()
        {
            {
                string input = @"
14
15
1  5
2  4
2  3
3  9
4  5
5  7
5  6
6  8
7 8
8 2
8 9
9 11
9 10
10 11
12 13
";

                Digraph <IntWrapper>     graph = new Digraph <IntWrapper>(input, (string s) => new IntWrapper(int.Parse(s)));
                IEnumerable <IntWrapper> sort  = Postorder.Sort(graph, new List <IntWrapper>()
                {
                    new IntWrapper(1)
                });
                foreach (IntWrapper n in sort)
                {
                    System.Console.Error.WriteLine(n);
                }
            }
            {
                string input = @"
6
5
1  2
2  4
2  5
1  3
3  6
";

                Digraph <IntWrapper>     graph = new Digraph <IntWrapper>(input, (string s) => new IntWrapper(int.Parse(s)));
                IEnumerable <IntWrapper> sort  = Postorder.Sort(graph, new List <IntWrapper>()
                {
                    new IntWrapper(1)
                });
                foreach (IntWrapper n in sort)
                {
                    System.Console.Error.WriteLine(n);
                }
            }
        }