Table of Contents

Class DirectedAdjacencyMatrixGraph<TVertex, TEdge>

Namespace
Graph1x
Assembly
Graph1x.dll

A simple directed graph stored as a dense adjacency matrix: O(1) edge lookup and removal at O(V²) memory, the right trade-off for dense graphs.

public sealed class DirectedAdjacencyMatrixGraph<TVertex, TEdge> : AdjacencyMatrixGraphBase<TVertex, TEdge>, IMutableGraph<TVertex, TEdge>, IDirectedGraph<TVertex, TEdge>, IReadOnlyGraph<TVertex, TEdge> where TVertex : notnull where TEdge : IEdge<TVertex>

Type Parameters

TVertex

The vertex type.

TEdge

The edge type.

Inheritance
AdjacencyMatrixGraphBase<TVertex, TEdge>
DirectedAdjacencyMatrixGraph<TVertex, TEdge>
Implements
IMutableGraph<TVertex, TEdge>
IDirectedGraph<TVertex, TEdge>
IReadOnlyGraph<TVertex, TEdge>
Inherited Members
Extension Methods

Constructors

DirectedAdjacencyMatrixGraph()

Initializes an empty graph using the default vertex comparer.

public DirectedAdjacencyMatrixGraph()

DirectedAdjacencyMatrixGraph(IEqualityComparer<TVertex>)

Initializes an empty graph using vertexComparer to identify vertices.

public DirectedAdjacencyMatrixGraph(IEqualityComparer<TVertex> vertexComparer)

Parameters

vertexComparer IEqualityComparer<TVertex>

The comparer used to identify vertices.

Exceptions

ArgumentNullException

vertexComparer is null.

Properties

IsDirected

Gets a value indicating whether edges are directed.

public override bool IsDirected { get; }

Property Value

bool

Methods

InDegree(TVertex)

Gets the number of edges entering vertex.

public int InDegree(TVertex vertex)

Parameters

vertex TVertex

The vertex to measure.

Returns

int

The in-degree.

Exceptions

ArgumentException

The vertex is not in the graph.

InEdges(TVertex)

Gets the edges entering vertex.

public IEnumerable<TEdge> InEdges(TVertex vertex)

Parameters

vertex TVertex

The vertex whose incoming edges to enumerate.

Returns

IEnumerable<TEdge>

The incoming edges.

Exceptions

ArgumentException

The vertex is not in the graph.

OutDegree(TVertex)

Gets the number of edges leaving vertex.

public int OutDegree(TVertex vertex)

Parameters

vertex TVertex

The vertex to measure.

Returns

int

The out-degree.

Exceptions

ArgumentException

The vertex is not in the graph.

OutEdges(TVertex)

Gets the edges leaving vertex.

public IEnumerable<TEdge> OutEdges(TVertex vertex)

Parameters

vertex TVertex

The vertex whose outgoing edges to enumerate.

Returns

IEnumerable<TEdge>

The outgoing edges.

Exceptions

ArgumentException

The vertex is not in the graph.