forked from aalhour/C-Sharp-Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIGraph.cs
128 lines (103 loc) · 3.77 KB
/
IGraph.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
using System;
using System.Collections.Generic;
using DataStructures.Lists;
namespace DataStructures.Graphs
{
public interface IGraph<T> where T : IComparable<T>
{
/// <summary>
/// Returns true, if graph is directed; false otherwise.
/// </summary>
bool IsDirected { get; }
/// <summary>
/// Returns true, if graph is weighted; false otherwise.
/// </summary>
bool IsWeighted { get; }
/// <summary>
/// Gets the count of vetices.
/// </summary>
int VerticesCount { get; }
/// <summary>
/// Gets the count of edges.
/// </summary>
int EdgesCount { get; }
/// <summary>
/// Returns the list of Vertices.
/// </summary>
IEnumerable<T> Vertices { get; }
/// <summary>
/// An enumerable collection of edges.
/// </summary>
IEnumerable<IEdge<T>> Edges { get; }
/// <summary>
/// Get all incoming edges from vertex
/// </summary>
IEnumerable<IEdge<T>> IncomingEdges(T vertex);
/// <summary>
/// Get all outgoing edges from vertex
/// </summary>
IEnumerable<IEdge<T>> OutgoingEdges(T vertex);
/// <summary>
/// Connects two vertices together.
/// </summary>
bool AddEdge(T firstVertex, T secondVertex);
/// <summary>
/// Deletes an edge, if exists, between two vertices.
/// </summary>
bool RemoveEdge(T firstVertex, T secondVertex);
/// <summary>
/// Adds a list of vertices to the graph.
/// </summary>
void AddVertices(IList<T> collection);
/// <summary>
/// Adds a new vertex to graph.
/// </summary>
bool AddVertex(T vertex);
/// <summary>
/// Removes the specified vertex from graph.
/// </summary>
bool RemoveVertex(T vertex);
/// <summary>
/// Checks whether two vertices are connected (there is an edge between firstVertex & secondVertex)
/// </summary>
bool HasEdge(T firstVertex, T secondVertex);
/// <summary>
/// Determines whether this graph has the specified vertex.
/// </summary>
bool HasVertex(T vertex);
/// <summary>
/// Returns the neighbours doubly-linked list for the specified vertex.
/// </summary>
DLinkedList<T> Neighbours(T vertex);
/// <summary>
/// Returns the degree of the specified vertex.
/// </summary>
int Degree(T vertex);
/// <summary>
/// Returns a human-readable string of the graph.
/// </summary>
string ToReadable();
/// <summary>
/// A depth first search traversal of the graph. Prints nodes as they get visited.
/// It considers the first inserted vertex as the start-vertex for the walk.
/// </summary>
IEnumerable<T> DepthFirstWalk();
/// <summary>
/// A depth first search traversal of the graph, starting from a specified vertex. Prints nodes as they get visited.
/// </summary>
IEnumerable<T> DepthFirstWalk(T startingVertex);
/// <summary>
/// A breadth first search traversal of the graph. Prints nodes as they get visited.
/// It considers the first inserted vertex as the start-vertex for the walk.
/// </summary>
IEnumerable<T> BreadthFirstWalk();
/// <summary>
/// A breadth first search traversal of the graph, starting from a specified vertex. Prints nodes as they get visited.
/// </summary>
IEnumerable<T> BreadthFirstWalk(T startingVertex);
/// <summary>
/// Clear this graph.
/// </summary>
void Clear();
}
}