Shields.Graphs.Tests/GraphTests.cs
/// <summary>
/// Property-based test of OrderTopologically. A topsort should contain the same
/// set of nodes and should satisfy all of the constraints indicated by the edges.
/// </summary>
Property-based test of OrderTopologically. A topsort should contain the same
set of nodes and should satisfy all of the constraints indicated by the edges.
Property - based test of OrderTopologically . A topsort should contain the same set of nodes and should satisfy all of the constraints indicated by the edges .
[TestMethod]
        public void OrderTopologicallyWorksOnAllSmallDags()
        {
            for (int order = 0; order <= 6; order++)
            {
                var nodes = Enumerable.Range('A', order).ToList();
                foreach (var descriptor in GraphGenerator.AllDirectedAcyclicGraphs(nodes))
                {
                    var topsort = nodes.OrderTopologically(descriptor).ToList();
                    CollectionAssert.AreEqual(nodes.OrderBy(u => u).ToList(), topsort.OrderBy(u => u).ToList());
                    foreach (var u in nodes)
                    {
                        foreach (var v in descriptor.Next(u))
                        {
                            Assert.IsTrue(topsort.IndexOf(u) < topsort.IndexOf(v));
                        }
                    }
                }
            }
        }
[ TestMethod ] public void OrderTopologicallyWorksOnAllSmallDags ( ) { for ( int order = 0 ; order <= 6 ; order ++ ) { var nodes = Enumerable . Range ( ' ' , order ) . ToList ( ) ; foreach ( var descriptor in GraphGenerator . AllDirectedAcyclicGraphs ( nodes ) ) { var topsort = nodes . OrderTopologically ( descriptor ) . ToList ( ) ; CollectionAssert . AreEqual ( nodes . OrderBy ( u => u ) . ToList ( ) , topsort . OrderBy ( u => u ) . ToList ( ) ) ; foreach ( var u in nodes ) { foreach ( var v in descriptor . Next ( u ) ) { Assert . IsTrue ( topsort . IndexOf ( u ) < topsort . IndexOf ( v ) ) ; } } } } }
Property-based test of OrderTopologically.
Property - based test of OrderTopologically .