Table of Contents

Class EdgeWeightedGraphWithAdjacencyLists<TWeight>

Namespace
AlgorithmsSW.EdgeWeightedGraph
Assembly
AlgorithmsSW.dll

Represents a weighted graph data structure.

public class EdgeWeightedGraphWithAdjacencyLists<TWeight> : IEdgeWeightedGraph<TWeight>, IReadOnlyEdgeWeightedGraph<TWeight>, IReadOnlyGraph, IEnumerable<(int vertex0, int vertex1)>, IEnumerable

Type Parameters

TWeight

The type of the edge weights.

Inheritance
EdgeWeightedGraphWithAdjacencyLists<TWeight>
Implements
Inherited Members
Extension Methods

Constructors

EdgeWeightedGraphWithAdjacencyLists(EdgeWeightedGraphWithAdjacencyLists<TWeight>)

public EdgeWeightedGraphWithAdjacencyLists(EdgeWeightedGraphWithAdjacencyLists<TWeight> graph)

Parameters

graph EdgeWeightedGraphWithAdjacencyLists<TWeight>

EdgeWeightedGraphWithAdjacencyLists(int)

public EdgeWeightedGraphWithAdjacencyLists(int vertexCount)

Parameters

vertexCount int

EdgeWeightedGraphWithAdjacencyLists(int, IEnumerable<Edge<TWeight>>)

public EdgeWeightedGraphWithAdjacencyLists(int vertexCount, IEnumerable<Edge<TWeight>> edges)

Parameters

vertexCount int
edges IEnumerable<Edge<TWeight>>

Properties

EdgeCount

Gets the number of edges in the graph.

public int EdgeCount { get; }

Property Value

int

SupportsParallelEdges

Gets a value indicating whether the graph supports parallel edges.

public bool SupportsParallelEdges { get; }

Property Value

bool

Remarks

This can be used to ensure algorithms are implemented correctly.

SupportsSelfLoops

Gets a value indicating whether the graph supports self-loops.

public bool SupportsSelfLoops { get; }

Property Value

bool

Remarks

This can be used to ensure algorithms are implemented correctly.

VertexCount

Gets the number of vertices in the graph.

public int VertexCount { get; }

Property Value

int

Vertexes

Gets the vertices in the graph.

public IEnumerable<int> Vertexes { get; }

Property Value

IEnumerable<int>

WeightedEdges

Gets the edges that is part of this IReadOnlyEdgeWeightedGraph<TWeight>.

public IEnumerable<Edge<TWeight>> WeightedEdges { get; }

Property Value

IEnumerable<Edge<TWeight>>

Methods

AddEdge(Edge<TWeight>)

Adds an edge to the graph.

public void AddEdge(Edge<TWeight> edge)

Parameters

edge Edge<TWeight>

The edge to add.

ContainsEdge(int, int)

Gets whether the graph contains an edge between two vertices.

public bool ContainsEdge(int vertex0, int vertex1)

Parameters

vertex0 int
vertex1 int

Returns

bool

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.

GetIncidentEdges(int)

Gets the edges that is incident to the given vertex.

public IEnumerable<Edge<TWeight>> GetIncidentEdges(int vertex)

Parameters

vertex int

The vertex to get the incident edges of.

Returns

IEnumerable<Edge<TWeight>>

RemoveEdge(Edge<TWeight>)

Removes an edge from the graph.

public bool RemoveEdge(Edge<TWeight> edge)

Parameters

edge Edge<TWeight>

The edge to remove.

Returns

bool

ToString()

Returns a string that represents the current object.

[ExerciseReference(4, 3, 17)]
public override string ToString()

Returns

string

A string that represents the current object.