Class DiGraph<T>
A directed graph implementation using dynamically growinng/shrinking adjacency matrix array.
IEnumerable enumerates all vertices.
Assembly: Advanced.Algorithms.dll
Syntax
public class DiGraph<T> : IEnumerable<T>, IEnumerable
Type Parameters
Constructors
DiGraph()
Declaration
Properties
VerticesCount
Declaration
public int VerticesCount { get; }
Property Value
Methods
AddEdge(T, T)
add an edge from source to destination vertex
Time complexity: O(1).
Declaration
public void AddEdge(T source, T dest)
Parameters
Type |
Name |
Description |
T |
source |
|
T |
dest |
|
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 |
|
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
HasEdge(T, T)
do we have an edge between the 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
InEdges(T)
Declaration
public IEnumerable<T> InEdges(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
OutEdges(T)
Declaration
public IEnumerable<T> OutEdges(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
RemoveEdge(T, T)
remove an existing edge between source and destination
Time complexity: O(1).
Declaration
public void RemoveEdge(T source, T dest)
Parameters
Type |
Name |
Description |
T |
source |
|
T |
dest |
|
RemoveVertex(T)
Remove an existing vertex from graph
Time complexity: O(V) where V is the number of vertices.
Declaration
public void RemoveVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Implements