Class IntGraph<T>
Class representing a graph of ints which is in fact an alias for a generic graph.
Inheritance
Implements
Namespace: Edgar.Graphs
Assembly: Edgar.dll
Syntax
public class IntGraph<T> : Object, IGraph<int>
Type Parameters
Name | Description |
---|---|
T | Generic type of the original graph. |
Remarks
The idea is to provide an integer interface that may save some time because the vertices can be used directly as indices to an array instead of using something like dictionary for storing values.
Constructors
IntGraph(IGraph<T>, Func<IGraph<Int32>>)
Creates a graph with the same vertices and edges as a given graph.
Declaration
public IntGraph(IGraph<T> originalGraph, Func<IGraph<int>> graphCreator)
Parameters
Type | Name | Description |
---|---|---|
IGraph<T> | originalGraph | |
System.Func<IGraph<System.Int32>> | graphCreator | Returns an instance of a graph that will be used as an underlying data structure. |
IntGraph(Func<IGraph<Int32>>)
Creates a graph which will use a graph returned from a given graphCreator as an underlying data structure.
Declaration
public IntGraph(Func<IGraph<int>> graphCreator)
Parameters
Type | Name | Description |
---|---|---|
System.Func<IGraph<System.Int32>> | graphCreator | Returns an instance of a graph that will be used as an underlying data structure. |
Properties
Edges
Gets all edges of the graph.
Declaration
public IEnumerable<IEdge<int>> Edges { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<IEdge<System.Int32>> |
IsDirected
Checks if the graph is directed.
Declaration
public bool IsDirected { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Vertices
Gets all vertices of the graph.
Declaration
public IEnumerable<int> Vertices { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
VerticesCount
Gets the total number of vertices.
Declaration
public int VerticesCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
AddEdge(T, T)
Adds an edge to the graph.
Declaration
public void AddEdge(T from, T to)
Parameters
Type | Name | Description |
---|---|---|
T | from | |
T | to |
AddVertex(T)
Adds a given vertex and creates a mapping from the vertex to an int.
Declaration
public void AddVertex(T vertex)
Parameters
Type | Name | Description |
---|---|---|
T | vertex |
GetNeighbours(Int32)
Gets all neighbours of a given vertex.
Declaration
public IEnumerable<int> GetNeighbours(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.Int32> |
GetOriginalVertex(Int32)
Gets the original vertex for a given integer alias.
Declaration
public T GetOriginalVertex(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |
Returns
Type | Description |
---|---|
T |
GetVertexAlias(T)
Gets the alias for a given vertex.
Declaration
public int GetVertexAlias(T vertex)
Parameters
Type | Name | Description |
---|---|---|
T | vertex |
Returns
Type | Description |
---|---|
System.Int32 |
HasEdge(Int32, Int32)
Checks whether there exists a given edge.
Declaration
public bool HasEdge(int from, int to)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | from | |
System.Int32 | to |
Returns
Type | Description |
---|---|
System.Boolean |
Explicit Interface Implementations
IGraph<Int32>.AddEdge(Int32, Int32)
Adding integer edges is not supported. Use AddEdge(T from, T to).
Declaration
void IGraph<int>.AddEdge(int from, int to)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | from | |
System.Int32 | to |
IGraph<Int32>.AddVertex(Int32)
Adding integer vertices is not supported. Use AddVertex(T vertex).
Declaration
void IGraph<int>.AddVertex(int vertex)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | vertex |