-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgorithms.hpp
31 lines (26 loc) · 1.02 KB
/
Algorithms.hpp
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
#pragma once
#include "Graph.hpp"
#include <vector>
#include <algorithm>
#include <iostream>
#include <limits>
#include <queue>
using namespace std;
const int INF = numeric_limits<int>::max();
const int NEG_INF = numeric_limits<int>::min();
namespace ariel
{
class Algorithms
{
private:
static bool dfs(size_t v, vector<bool> &visited, vector<bool> &recStack, const vector<vector<int>> &graph, vector<size_t> &parent);
static bool isComponentBipartite(size_t start, const vector<vector<int>> &graph, vector<size_t> &colors, vector<vector<size_t>> &groups);
static bool bellmanFord(size_t start, const vector<vector<int>> &graph, vector<int> &distance, vector<size_t> &parent);
public:
static bool isConnected(const Graph &g);
static vector<size_t> shortestPath(const Graph &g, size_t start, size_t end);
static bool isContainsCycle(const Graph &g);
static bool isBipartite(const Graph &g);
static bool negativeCycle(const Graph &g);
};
} // namespace ariel