Class WeightedGraph<T, TW>
A weighted graph implementation.
IEnumerable enumerates all vertices.
Inheritance
WeightedGraph<T, TW>
Implements
IEnumerable<T>
Assembly: Advanced.Algorithms.dll
Syntax
public class WeightedGraph<T, TW> : IGraph<T>, IEnumerable<T> where TW : IComparable
Type Parameters
Constructors
WeightedGraph()
Declaration
Properties
IsWeightedGraph
Declaration
public bool IsWeightedGraph { get; }
Property Value
VerticesAsEnumberable
Declaration
public IEnumerable<IGraphVertex<T>> VerticesAsEnumberable { get; }
Property Value
Type |
Description |
IEnumerable<IGraphVertex<T>> |
|
VerticesCount
Declaration
public int VerticesCount { get; }
Property Value
Methods
AddEdge(T, T, TW)
Add a new edge to this graph with given weight
and between given source and destination vertex.
Time complexity: O(1).
Declaration
public void AddEdge(T source, T dest, TW weight)
Parameters
Type |
Name |
Description |
T |
source |
|
T |
dest |
|
TW |
weight |
|
AddVertex(T)
Add a new vertex to this graph.
Time complexity: O(1).
Declaration
public void AddVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Clone()
Declaration
public WeightedGraph<T, TW> Clone()
Returns
ContainsVertex(T)
Declaration
public bool ContainsVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
GetAllEdges(T)
Declaration
public List<Tuple<T, TW>> GetAllEdges(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
Type |
Description |
List<Tuple<T, TW>> |
|
GetEnumerator()
Declaration
public IEnumerator GetEnumerator()
Returns
Type |
Description |
IEnumerator |
|
GetVertex(T)
Declaration
public IGraphVertex<T> GetVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
Type |
Description |
IGraphVertex<T> |
|
HasEdge(T, T)
Do we have an edge between given source and destination?
Time complexity: O(1).
Declaration
public bool HasEdge(T source, T dest)
Parameters
Type |
Name |
Description |
T |
source |
|
T |
dest |
|
Returns
RemoveEdge(T, T)
Remove given edge.
Time complexity: O(1).
Declaration
public void RemoveEdge(T source, T dest)
Parameters
Type |
Name |
Description |
T |
source |
|
T |
dest |
|
RemoveVertex(T)
Remove given vertex from this graph.
Time complexity: O(V) where V is the number of vertices.
Declaration
public void RemoveVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Implements
IEnumerable<>