Table of Contents

Class DigraphWithAdjacentsLists

Namespace
AlgorithmsSW.Digraph
Assembly
AlgorithmsSW.dll

Represents a directed graph using an array of adjacency lists.

public sealed class DigraphWithAdjacentsLists : IDigraph, IReadOnlyDigraph, IEnumerable<(int vertex0, int vertex1)>, IEnumerable
Inheritance
DigraphWithAdjacentsLists
Implements
Inherited Members
Extension Methods

Constructors

DigraphWithAdjacentsLists(IDigraph)

[ExerciseReference(4, 2, 3)]
public DigraphWithAdjacentsLists(IDigraph digraph)

Parameters

digraph IDigraph

DigraphWithAdjacentsLists(int)

Initializes a new instance of the DigraphWithAdjacentsLists class.

public DigraphWithAdjacentsLists(int vertexCount)

Parameters

vertexCount int

The number of vertices in the graph.

DigraphWithAdjacentsLists(int, EdgeList)

Initializes a new instance of the DigraphWithAdjacentsLists class.

public DigraphWithAdjacentsLists(int vertexCount, EdgeList edges)

Parameters

vertexCount int

The number of vertices in the graph.

edges EdgeList

The edges to add to the graph.

Properties

EdgeCount

Gets the number of edges in the graph.

public int EdgeCount { get; }

Property Value

int

Edges

public IEnumerable<(int, int)> Edges { get; }

Property Value

IEnumerable<(int source, int target)>

SupportsParallelEdges

public bool SupportsParallelEdges { get; }

Property Value

bool

SupportsSelfLoops

public bool SupportsSelfLoops { get; }

Property Value

bool

VertexCount

Gets the number of vertices in the graph.

public int VertexCount { get; }

Property Value

int

Methods

Add((int vertex0, int vertex1))

public void Add((int vertex0, int vertex1) edge)

Parameters

edge (int vertex0, int vertex1)

AddEdge(int, int)

Adds an edge between two vertices in the graph.

public void AddEdge(int vertex0, int vertex1)

Parameters

vertex0 int

The first vertex of the edge to add.

vertex1 int

The second vertex of the edge to add.

ContainsEdge(int, int)

Checks if the graph contains an edge between from one vertex to another.

[ExerciseReference(4, 2, 3)]
public bool ContainsEdge(int vertex0, int vertex1)

Parameters

vertex0 int

The start of the edge.

vertex1 int

The end of the edge.

Returns

bool

true if the graph contains the edge, false otherwise.

GetAdjacents(int)

Gets the adjacent vertices of a given vertex.

public IEnumerable<int> GetAdjacents(int vertex)

Parameters

vertex int

The vertex to find adjacents for.

Returns

IEnumerable<int>

An enumerable of adjacent vertices.

GetEnumerator()

Returns an enumerator that iterates through the collection.

public IEnumerator<(int vertex0, int vertex1)> GetEnumerator()

Returns

IEnumerator<(int vertex0, int vertex1)>

An enumerator that can be used to iterate through the collection.

RemoveEdge(int, int)

Removes an edge between two vertices in the graph.

public bool RemoveEdge(int vertex0, int vertex1)

Parameters

vertex0 int

The first vertex of the edge to remove.

vertex1 int

The second vertex of the edge to remove.

Returns

bool

true if the edge was removed, false otherwise.