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
intThe number of vertices in the graph.
DigraphWithAdjacentsLists(int, EdgeList)
Initializes a new instance of the DigraphWithAdjacentsLists class.
public DigraphWithAdjacentsLists(int vertexCount, EdgeList edges)
Parameters
Properties
EdgeCount
Gets the number of edges in the graph.
public int EdgeCount { get; }
Property Value
Edges
public IEnumerable<(int, int)> Edges { get; }
Property Value
- IEnumerable<(int source, int target)>
SupportsParallelEdges
public bool SupportsParallelEdges { get; }
Property Value
SupportsSelfLoops
public bool SupportsSelfLoops { get; }
Property Value
VertexCount
Gets the number of vertices in the graph.
public int VertexCount { get; }
Property Value
Methods
Add((int vertex0, int vertex1))
public void Add((int vertex0, int vertex1) edge)
Parameters
AddEdge(int, int)
Adds an edge between two vertices in the graph.
public void AddEdge(int vertex0, int vertex1)
Parameters
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
Returns
GetAdjacents(int)
Gets the adjacent vertices of a given vertex.
public IEnumerable<int> GetAdjacents(int vertex)
Parameters
vertex
intThe 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
intThe first vertex of the edge to remove.
vertex1
intThe second vertex of the edge to remove.