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); }
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); }