Ejemplo n.º 1
0
        public void LeadsOutOf(string pathDescription, string edgeDescription, bool expected)
        {
            var path = GraphFactory.CreatePath(pathDescription.Select(c => c.ToString()).ToArray());
            var edge = GraphFactory.CreateEdge(edgeDescription);

            edge.LeadsOutOf(path).Should().Be(expected);
        }
Ejemplo n.º 2
0
        public void CannotChangeItsSetOfEdges()
        {
            var edges = GraphFactory.CreateEdges("A-B").ToList();
            var nodes = GraphFactory.CreateNodes("A", "B");
            var graph = DirectedGraph.Of(edges, nodes);

            graph.EdgeCount.Should().Be(1);
            edges.Add(GraphFactory.CreateEdge("B-A"));
            graph.EdgeCount.Should().Be(1);
        }
Ejemplo n.º 3
0
        private IEnumerable <DirectedEdge> CreateEdges(string sequence)
        {
            if (string.IsNullOrEmpty(sequence))
            {
                yield break;
            }
            var prev = sequence[0];

            foreach (var c in sequence.Skip(1))
            {
                yield return(GraphFactory.CreateEdge(string.Format("{0}-{1}", prev, c)));

                prev = c;
            }
        }