-
Notifications
You must be signed in to change notification settings - Fork 0
/
Graph.h
52 lines (44 loc) · 1.28 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
//
// Created by manue on 30/12/2022.
//
#ifndef AIRPLANES_GRAPH_H
#define AIRPLANES_GRAPH_H
#include <string>
#include <list>
#include <unordered_set>
#include <vector>
#include <stack>
struct Edge {
int dest;
std::string airlineCode;
};
struct Node {
std::string airportCode;
std::list<Edge> adj;
bool visited;
int distance;
int previous;
int num;
int low;
bool inStack;
};
class Graph {
public:
Graph(int n);
int getN() const;
const std::vector<Node> &getNodes() const;
std::vector<std::string> getAirlinesCodes(int src, int dest, const std::unordered_set<std::string> &filter = {}) const;
std::vector<int> getMinPath(int dest, int min) const;
void addNode(const std::string &airportCode);
void addEdge(int source, int target, const std::string &airlineCode);
void unvisitNodes();
void bfs_distance(int v);
void bfs_flights(const std::unordered_set<int> &sources, const std::unordered_set<int> &targets = {}, const std::unordered_set<std::string> &filter = {});
void dfs_art(int v, bool isRoot, int &index, std::unordered_set<std::string> &points);
void dfs_scc(int v, int &index, std::stack<int> &s, int &scc);
unsigned diameter();
private:
int n;
std::vector<Node> nodes;
};
#endif //AIRPLANES_GRAPH_H