Interface IReadOnlyGraph<TVertex, TEdge>
- Namespace
- Graph1x
- Assembly
- Graph1x.dll
Read-only view over a graph: vertex/edge enumeration and structural queries. All graph implementations, directed or undirected, sparse or dense, expose this contract.
public interface IReadOnlyGraph<TVertex, TEdge> where TVertex : notnull where TEdge : IEdge<TVertex>
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
- Extension Methods
Properties
AllowsParallelEdges
Gets a value indicating whether the graph admits parallel edges between the same endpoints.
bool AllowsParallelEdges { get; }
Property Value
EdgeCount
Gets the number of edges in the graph.
int EdgeCount { get; }
Property Value
Edges
Gets the edges of the graph.
IEnumerable<TEdge> Edges { get; }
Property Value
- IEnumerable<TEdge>
IsDirected
Gets a value indicating whether edges are directed.
bool IsDirected { get; }
Property Value
VertexComparer
Gets the comparer used to identify vertices.
IEqualityComparer<TVertex> VertexComparer { get; }
Property Value
- IEqualityComparer<TVertex>
VertexCount
Gets the number of vertices in the graph.
int VertexCount { get; }
Property Value
Vertices
Gets the vertices of the graph.
IEnumerable<TVertex> Vertices { get; }
Property Value
- IEnumerable<TVertex>
Methods
AdjacentEdges(TVertex)
Gets the edges incident to vertex. On directed graphs
this includes both incoming and outgoing edges.
IEnumerable<TEdge> AdjacentEdges(TVertex vertex)
Parameters
vertexTVertexThe vertex whose incident edges to enumerate.
Returns
- IEnumerable<TEdge>
The incident edges.
Exceptions
- ArgumentException
The vertex is not in the graph.
ContainsEdge(TVertex, TVertex)
Determines whether the graph contains an edge between source
and target. On undirected graphs the endpoint order is irrelevant.
bool ContainsEdge(TVertex source, TVertex target)
Parameters
sourceTVertexThe first endpoint.
targetTVertexThe second endpoint.
Returns
ContainsVertex(TVertex)
Determines whether the graph contains vertex.
bool ContainsVertex(TVertex vertex)
Parameters
vertexTVertexThe vertex to look up.
Returns
Degree(TVertex)
Gets the degree of vertex. Self-loops count twice on
undirected graphs; on directed graphs the degree is in-degree plus out-degree.
int Degree(TVertex vertex)
Parameters
vertexTVertexThe vertex to measure.
Returns
- int
The number of edge endpoints incident to the vertex.
Exceptions
- ArgumentException
The vertex is not in the graph.