Table of Contents

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

TVertex

The 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

bool

true if edges are directed; false if undirected.

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

vertex TVertex

The vertex to locate.

Returns

bool

true if the vertex exists; otherwise, false.

Degree(TVertex)

Returns the number of out-edges of the specified vertex (its degree, for an undirected graph).

int Degree(TVertex vertex)

Parameters

vertex TVertex

The 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

vertex TVertex

The vertex whose neighbors are requested.

Returns

IEnumerable<TVertex>

The neighboring vertices.

Applies to

ProductVersions
.NET8, 10