-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.h
More file actions
37 lines (28 loc) · 713 Bytes
/
graph.h
File metadata and controls
37 lines (28 loc) · 713 Bytes
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
#ifndef GRAPH_H
#define GRAPH_H
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <stack>
#include <fstream>
// Class: Graph
// a simple graph class that holds number of vertices and an adjacency list
class Graph
{
int nVertices;
// adjacency list
std::list<int> *adj;
// A function used by topologicalSort
void topologicalSortUtil(int v, bool visited[], std::stack<int> &Stack);
public:
Graph(int nVertices);
// function to add an edge to graph
void addEdge(int originVertex, int destinyVertex);
// DFS based topological sort
void topologicalSort();
// kahn's algorithm to topological sort
void kahnTopologicalSort();
int getNVertices();
};
#endif