IReadOnlyGraph<TVertex> Interface
Definition
- Namespace
- Bodu.Collections.Generic.Graphs
- Assembly
- Bodu.Collections.dll
- Package
- Bodu.Collections 1.0.0
- Source
- IReadOnlyGraph{T}.cs
Defines a read-only view over a vertex-and-edge graph: the topology queries the graph algorithms depend on, independent of how the graph is stored.
public interface IReadOnlyGraph<TVertex> where TVertex : notnull
Type Parameters
TVertexThe vertex type.
- Extension Methods
Remarks
Algorithms that do not need edge weights (traversal, topological sort, connectivity) accept this interface so they can run over any graph representation, not only the default Graph<T> adjacency-list implementation.
Properties
Comparer
Gets the comparer used to determine vertex equality.
IEqualityComparer<TVertex> Comparer { get; }
Property Value
- IEqualityComparer<TVertex>
The vertex comparer.
EdgeCount
Gets the number of edges in the graph.
int EdgeCount { get; }
Property Value
- int
The edge count.
IsDirected
Gets a value indicating whether edges are directed.
bool IsDirected { get; }
Property Value
VertexCount
Gets the number of vertices in the graph.
int VertexCount { get; }
Property Value
- int
The vertex count.
Vertices
Gets the vertices in the graph.
IReadOnlyCollection<TVertex> Vertices { get; }
Property Value
- IReadOnlyCollection<TVertex>
A read-only collection of the graph's vertices.
Methods
ContainsVertex(TVertex)
Determines whether the graph contains the specified vertex.
bool ContainsVertex(TVertex vertex)
Parameters
vertexTVertexThe vertex to locate.
Returns
Degree(TVertex)
Returns the number of out-edges of the specified vertex (its degree, for an undirected graph).
int Degree(TVertex vertex)
Parameters
vertexTVertexThe vertex whose degree is requested.
Returns
- int
The out-degree of the vertex.
Neighbors(TVertex)
Returns the successor vertices reachable from the specified vertex.
IEnumerable<TVertex> Neighbors(TVertex vertex)
Parameters
vertexTVertexThe vertex whose neighbors are requested.
Returns
- IEnumerable<TVertex>
The neighboring vertices.
Applies to
| Product | Versions |
|---|---|
| .NET | 8, 10 |