-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGraph.h
29 lines (28 loc) · 1.47 KB
/
Graph.h
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
#pragma once
#include <iostream>
#include <vector>
#include <set>
#include <stack>
#include <string>
#include <math.h>
using namespace std;
#define NIL -1
#define INFINITY 10000000
class Graph
{
static vector<set<int>> getTranspose(const vector<set<int>>& _d);
static vector<int> DFSUtil(int v, bool visited[], const vector<set<int>>& _d);
static void fillOrder(int v, bool visited[], stack<int>& Stack, const vector<set<int>>& _d);
static vector<pair<int, int>> bridgeUtil(int* time, int v, bool visited[], int disc[], int low[], int parent[], const vector<set<int>>& _d);
static void topologicalSortUtil(int v, bool visited[], stack<int>& Stack, const vector<set<int>>& _d);
static bool isCyclicUtil(int v, bool visited[], int parent, const vector<set<int>>& _d);
static void GetAllPathsUtil(int u, bool visited[], int path[], int& path_index, const vector<set<int>>& _d, vector<vector<int>>& _paths);
static void APUtil(int u, bool visited[], int disc[], int low[], int parent[], bool ap[], const vector<set<int>>& _d);
public:
static vector<vector<int>> GetStronglyConnectedComponents(const vector<set<int>>& _d);
static vector<pair<int, int>> bridge(const vector<set<int>>& _d);
static vector<int> topologicalSort(const vector<set<int>>& _d);
static bool isTree(const vector<set<int>>& _d);
static void GetAllPaths(int s, const vector<set<int>>& _d, vector<vector<int>>& _paths);
static vector<int> AP(const vector<set<int>>& _d, vector<int>& Level);
};