Class DiGraph<T>
A directed graph implementation using dynamically growing/shrinking adjacency matrix array.
IEnumerable enumerates all vertices.
Implements
IDiGraph<T>
IEnumerable<T>
Assembly: Advanced.Algorithms.dll
Syntax
public class DiGraph<T> : IGraph<T>, IDiGraph<T>, IEnumerable<T>
Type Parameters
Constructors
DiGraph()
Declaration
Properties
IsWeightedGraph
Declaration
public bool IsWeightedGraph { get; }
Property Value
ReferenceVertex
Declaration
public IGraphVertex<T> ReferenceVertex { get; }
Property Value
Type |
Description |
IGraphVertex<T> |
|
VerticesAsEnumberable
Declaration
public IEnumerable<IDiGraphVertex<T>> VerticesAsEnumberable { get; }
Property Value
Type |
Description |
IEnumerable<IDiGraphVertex<T>> |
|
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 |
|
Clone()
Declaration
public DiGraph<T> Clone()
Returns
ContainsVertex(T)
Declaration
public bool ContainsVertex(T key)
Parameters
Type |
Name |
Description |
T |
key |
|
Returns
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
Type |
Description |
IEnumerator<T> |
|
GetVertex(T)
Declaration
public IGraphVertex<T> GetVertex(T key)
Parameters
Type |
Name |
Description |
T |
key |
|
Returns
Type |
Description |
IGraphVertex<T> |
|
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
InEdgeCount(T)
Declaration
public int InEdgeCount(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
InEdges(T)
Declaration
public IEnumerable<T> InEdges(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
Type |
Description |
IEnumerable<T> |
|
OutEdgeCount(T)
Declaration
public int OutEdgeCount(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
Type |
Description |
IEnumerable<T> |
|
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 |
|
Implements
IDiGraph<>
IEnumerable<>