Class EdgeWeightedDigraphWithAdjacencyLists<TWeight>
- Namespace
- AlgorithmsSW.EdgeWeightedDigraph
- Assembly
- AlgorithmsSW.dll
Represents a directed edge weighted graph data structure using adjacency lists.
public class EdgeWeightedDigraphWithAdjacencyLists<TWeight> : IEdgeWeightedDigraph<TWeight>, IReadOnlyEdgeWeightedDigraph<TWeight>, IReadOnlyDigraph, IEnumerable<(int vertex0, int vertex1)>, IEnumerable
Type Parameters
TWeight
The type of the edge weights.
- Inheritance
-
EdgeWeightedDigraphWithAdjacencyLists<TWeight>
- Implements
-
IEdgeWeightedDigraph<TWeight>IReadOnlyEdgeWeightedDigraph<TWeight>
- Inherited Members
- Extension Methods
Constructors
EdgeWeightedDigraphWithAdjacencyLists(IReadOnlyEdgeWeightedDigraph<TWeight>)
Initializes a new instance of the EdgeWeightedDigraphWithAdjacencyLists<TWeight> class from the specified graph, but with a different comparer.
public EdgeWeightedDigraphWithAdjacencyLists(IReadOnlyEdgeWeightedDigraph<TWeight> graph)
Parameters
graph
IReadOnlyEdgeWeightedDigraph<TWeight>The graph to construct the new graph from.
EdgeWeightedDigraphWithAdjacencyLists(IReadOnlyEdgeWeightedGraph<TWeight>)
public EdgeWeightedDigraphWithAdjacencyLists(IReadOnlyEdgeWeightedGraph<TWeight> graph)
Parameters
graph
IReadOnlyEdgeWeightedGraph<TWeight>
EdgeWeightedDigraphWithAdjacencyLists(int)
Initializes a new instance of the EdgeWeightedDigraphWithAdjacencyLists<TWeight> class.
public EdgeWeightedDigraphWithAdjacencyLists(int vertexCount)
Parameters
vertexCount
intThe number of vertices in the graph.
Properties
EdgeCount
Gets the number of edges in the graph.
public int EdgeCount { get; }
Property Value
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
WeightedEdges
Gets the edges that is part of this IReadOnlyEdgeWeightedDigraph<TWeight>.
public IEnumerable<DirectedEdge<TWeight>> WeightedEdges { get; }
Property Value
- IEnumerable<DirectedEdge<TWeight>>
Methods
AddEdge(DirectedEdge<TWeight>)
Adds an edge to the graph.
public void AddEdge(DirectedEdge<TWeight> edge)
Parameters
edge
DirectedEdge<TWeight>The edge to add.
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.
GetIncidentEdges(int)
Gets the edges that is incident to the given vertex.
public IEnumerable<DirectedEdge<TWeight>> GetIncidentEdges(int vertex)
Parameters
vertex
intThe vertex to get the incident edges of.
Returns
- IEnumerable<DirectedEdge<TWeight>>
An enumerable of incident edges.
RemoveEdge(DirectedEdge<TWeight>)
Removes an edge from the graph.
public bool RemoveEdge(DirectedEdge<TWeight> edge)
Parameters
edge
DirectedEdge<TWeight>The edge to remove.
Returns
TryGetUniqueEdge(int, int, out DirectedEdge<TWeight>)
public bool TryGetUniqueEdge(int pairFirst, int pairLast, out DirectedEdge<TWeight> edge)
Parameters
pairFirst
intpairLast
intedge
DirectedEdge<TWeight>