Class GraphViewExtensions
- Namespace
- Graph1x
- Assembly
- Graph1x.dll
Read-only views and immutable snapshots over any graph. A view is live (later mutations of the underlying graph show through); a frozen graph is a deep copy that never changes and is safe for concurrent readers.
public static class GraphViewExtensions
- Inheritance
-
GraphViewExtensions
- Inherited Members
Methods
AsReadOnly<TVertex, TEdge>(IDirectedGraph<TVertex, TEdge>)
Wraps a directed graph in a live read-only view, keeping the IDirectedGraph<TVertex, TEdge> static type.
public static IDirectedGraph<TVertex, TEdge> AsReadOnly<TVertex, TEdge>(this IDirectedGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed graph to wrap.
Returns
- IDirectedGraph<TVertex, TEdge>
A read-only live view.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
Exceptions
- ArgumentNullException
graphis null.
AsReadOnly<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Wraps the graph in a live read-only view that cannot be cast back to IMutableGraph<TVertex, TEdge>. Directed graphs yield a view that still implements IDirectedGraph<TVertex, TEdge>; calling this on an existing view returns the same instance.
public static IReadOnlyGraph<TVertex, TEdge> AsReadOnly<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to wrap.
Returns
- IReadOnlyGraph<TVertex, TEdge>
A read-only live view.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
Exceptions
- ArgumentNullException
graphis null.
ToFrozen<TVertex, TEdge>(IDirectedGraph<TVertex, TEdge>)
Takes an immutable snapshot of a directed graph, keeping the IDirectedGraph<TVertex, TEdge> static type.
public static IDirectedGraph<TVertex, TEdge> ToFrozen<TVertex, TEdge>(this IDirectedGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIDirectedGraph<TVertex, TEdge>The directed graph to snapshot.
Returns
- IDirectedGraph<TVertex, TEdge>
An immutable copy.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
Exceptions
- ArgumentNullException
graphis null.
ToFrozen<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Takes an immutable snapshot of the graph: a deep copy (matching the source's direction and parallel-edge policy) wrapped read-only. The snapshot never changes and is safe for concurrent readers.
public static IReadOnlyGraph<TVertex, TEdge> ToFrozen<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to snapshot.
Returns
- IReadOnlyGraph<TVertex, TEdge>
An immutable copy.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
Exceptions
- ArgumentNullException
graphis null.