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