Interface IGraph
A graph data structure, directed or undirected.
Namespace: MoreStructures.Graphs
Assembly: MoreStructures.dll
Syntax
public interface IGraph
Remarks
DEFINITION
A graph is a data structure composed of two types of objects:
Both vertices and edges can carry labels, weights, costs, or any other piece of information, specific to the
scenario in which they are used.
More precisely, a graph is conceptually defined as a couple of two collections:
- a collection of vertices,
- and a collection of edges, connecting such vertices, directionally or undirectionally.
The actual underlying representation of a graph instance depends on the specific IGraph used.
Methods
| Improve this Doc View SourceGetAdjacentVerticesAndEdges(Int32, Boolean)
Returns the vertices of the graph which are neighbor of the start
vertex, each vertex
together with its incoming or outgoing edge, linking the vertex to the start
vertex.
Declaration
IEnumerable<IGraph.Adjacency> GetAdjacentVerticesAndEdges(int start, bool takeIntoAccountEdgeDirection)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | start | The id of the vertex, to look for neighbors of. |
System.Boolean | takeIntoAccountEdgeDirection | Whether to consider the direction of edges, when looking for neighbors. |
Returns
Type | Description |
---|---|
IEnumerable<IGraph.Adjacency> | A sequence of IGraph.Adjacency instances, containing the id of the neighboring vertex V found, and the
edge which connects the |
GetAllEdges()
Returns all the edges of this graph.
Declaration
IEnumerable<(int edgeStart, int edgeEnd)> GetAllEdges()
Returns
Type | Description |
---|---|
IEnumerable<System.ValueTuple<System.Int32, System.Int32>> | A sequence of couples (sourceVertex, targetVertex), each identifying an edge of the graph. |
GetNumberOfVertices()
Returns the total number of vertices of the graph.
Declaration
int GetNumberOfVertices()
Returns
Type | Description |
---|---|
System.Int32 | A non-negative integer. |
Reverse()
Builds the reverse graph, i.e. a graph with the same set of vertices and reversed edges: for each edge (u, v) of the graph G, there is one edge (v, u) in the reverse graph G^-1.
Declaration
IGraph Reverse()
Returns
Type | Description |
---|---|
IGraph | A new instance of IGraph, representing the reverse graph. |