Class Graph<T>
A graph implementation
IEnumerable enumerates all vertices.
Assembly: Advanced.Algorithms.dll
Syntax
public class Graph<T> : IEnumerable<T>, IEnumerable
Type Parameters
Constructors
Graph()
Declaration
Properties
ReferenceVertex
Returns a reference vertex.
Time complexity: O(1).
Declaration
public GraphVertex<T> ReferenceVertex { get; }
Property Value
VerticesCount
Declaration
public int VerticesCount { get; }
Property Value
Methods
AddEdge(T, T)
Add an edge to this graph.
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 GraphVertex<T> AddVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
Edges(T)
Declaration
public IEnumerable<T> Edges(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Returns
FindVertex(T)
Returns the vertex object with the given value.
Time complexity: O(1).
Declaration
public GraphVertex<T> FindVertex(T value)
Parameters
Type |
Name |
Description |
T |
value |
|
Returns
GetEnumerator()
Declaration
public IEnumerator<T> GetEnumerator()
Returns
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 an edge from this graph.
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 this graph.
Time complexity: O(V) where V is the number of vertices.
Declaration
public void RemoveVertex(T vertex)
Parameters
Type |
Name |
Description |
T |
vertex |
|
Explicit Interface Implementations
IEnumerable.GetEnumerator()
Declaration
IEnumerator IEnumerable.GetEnumerator()
Returns
Implements