Esempio n. 1
0
        public void DontFollowCycles()
        {
            var graph = new DirectedLabeledGraph <int, char>(1)
                        .Connect(1, 'a', 2)
                        .Connect(2, 'b', 3);

            var edgeOrder = new List <char>();

            graph.TraverseEdgesBF((source, edge, target) =>
            {
                edgeOrder.Add(edge);
            });

            Assert.AreEqual(2, edgeOrder.Count());
            Assert.IsTrue(edgeOrder.IndexOf('a') >= 0);
            Assert.IsTrue(edgeOrder.IndexOf('b') > edgeOrder.IndexOf('a'));
        }
Esempio n. 2
0
        public void TraverseSimpleGraph()
        {
            var graph = new DirectedLabeledGraph <int, char>(1)
                        .Connect(1, 'a', 2)
                        .Connect(2, 'b', 4)
                        .Connect(1, 'c', 3)
                        .Connect(3, 'd', 4);

            var edgeOrder = new List <char>();

            graph.TraverseEdgesBF((source, edge, target) =>
            {
                edgeOrder.Add(edge);
            });

            Assert.IsTrue(edgeOrder.IndexOf('a') >= 0);
            Assert.IsTrue(edgeOrder.IndexOf('c') >= 0);
            Assert.IsTrue(edgeOrder.IndexOf('b') > edgeOrder.IndexOf('a'));
            Assert.IsTrue(edgeOrder.IndexOf('d') > edgeOrder.IndexOf('c'));
        }