Exemplo n.º 1
0
        public void GraphExtensions_GetOrderedEdges_ReturnsOrderedEdgeDescriptors()
        {
            IGraph <string, string> graph = new AdjacencyList <string, string>();

            graph.AddVertex("BBB");
            graph.AddVertex("AAA");
            graph.AddVertex("ABA");
            graph.AddVertex("BAB");

            graph.AddEdge("ABA", "BBB", "aba-bbb");
            graph.AddEdge("ABA", "AAA", "aba-aaa");
            graph.AddEdge("ABA", "BAB", "aba-bab");
            // Those opposite edges will be ignored
            graph.AddEdge("AAA", "ABA", "aaa-aba");
            graph.AddEdge("BBB", "ABA", "bbb-aba");

            var edges = graph.FindVertexDescriptor("ABA").GetOrderedEdges(StringComparer.CurrentCulture);

            Assert.Equal(3, edges.Count());
            Assert.Equal("AAA", edges.ElementAt(0).Vertex2);
            Assert.Equal("BAB", edges.ElementAt(1).Vertex2);
            Assert.Equal("BBB", edges.ElementAt(2).Vertex2);
        }