Exemple #1
0
        public void AsDirected_ThenDirectedGraph()
        {
            // given
            Vertex <int> vertex         = testObject[5];
            string       vertexProperty = "123456";
            string       edgeProperty   = "zxcvb";
            Edge <int>   edge           = testObject.AddEdgeBetween(testObject[1], testObject[5]);

            testObject.AddEdgeBetween(testObject[7], testObject[7]);
            testObject.AddEdgeBetween(testObject[2], testObject[4]);
            testObject.AddEdgeBetween(testObject[8], testObject[0]);
            testObject.AddEdgeBetween(testObject[6], testObject[3]);
            testObject.AddEdgeBetween(testObject[9], testObject[3]);
            testObject.Properties[vertex] = vertexProperty;
            testObject.Properties[edge]   = edgeProperty;
            // when
            IDirectedGraph <int, string, string> result = testObject.AsDirected();

            // then
            result.Vertices.Should().BeEquivalentTo(testObject.Vertices);
            result.Edges.Should().BeEquivalentTo(
                new[] {
                new Edge <int>(new Vertex <int>(0), new Vertex <int>(8)),
                new Edge <int>(new Vertex <int>(1), new Vertex <int>(5)),
                new Edge <int>(new Vertex <int>(2), new Vertex <int>(4)),
                new Edge <int>(new Vertex <int>(3), new Vertex <int>(6)),
                new Edge <int>(new Vertex <int>(3), new Vertex <int>(9)),
                new Edge <int>(new Vertex <int>(4), new Vertex <int>(2)),
                new Edge <int>(new Vertex <int>(5), new Vertex <int>(1)),
                new Edge <int>(new Vertex <int>(6), new Vertex <int>(3)),
                new Edge <int>(new Vertex <int>(7), new Vertex <int>(7)),
                new Edge <int>(new Vertex <int>(8), new Vertex <int>(0)),
                new Edge <int>(new Vertex <int>(9), new Vertex <int>(3))
            });
            result.Properties[vertex].Should().Be(vertexProperty);
            result.Properties[result[9]].Should().BeNull();
            result.Properties[result[1, 5]].Should().Be(edgeProperty);
            result.Properties[result[5, 1]].Should().Be(edgeProperty);
            result.Properties[result[8, 0]].Should().BeNull();
        }
 public IDirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> AsDirected() =>
 graph.AsDirected();