public IDirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> ReversedCopy()
        {
            var reversedGraph = new DirectedSimpleGraph <TVertexId, TVertexProperty, TEdgeProperty>(
                Vertices.Select(v => v.Id));

            foreach (Vertex <TVertexId> vertex in Vertices)
            {
                reversedGraph.Properties[vertex] = Properties[vertex];
            }

            foreach (Edge <TVertexId> edge in Edges)
            {
                reversedGraph.AddEdge(edge.Reversed(), Properties[edge]);
            }

            return(reversedGraph);
        }
Esempio n. 2
0
        public IDirectedGraph <TVertexId, TVertexProperty, TEdgeProperty> AsDirected()
        {
            var directedSimpleGraph = new DirectedSimpleGraph <TVertexId, TVertexProperty, TEdgeProperty>(
                Vertices.Select(v => v.Id));

            foreach (Vertex <TVertexId> vertex in Vertices)
            {
                directedSimpleGraph.Properties[vertex] = Properties[vertex];
            }

            foreach (Edge <TVertexId> edge in Edges)
            {
                directedSimpleGraph.AddEdge(edge, Properties[edge]);

                if (edge.Source != edge.Destination)
                {
                    directedSimpleGraph.AddEdge(edge.Reversed(), Properties[edge]);
                }
            }

            return(directedSimpleGraph);
        }
Esempio n. 3
0
 public void SetUp() =>
 testObject = new DirectedSimpleGraph <int, string, string>(Enumerable.Range(0, 10));