2024-07-14 16:44:12 +02:00
|
|
|
#ifndef C___DIGRAPH_H
|
|
|
|
#define C___DIGRAPH_H
|
|
|
|
|
|
|
|
#include <list>
|
|
|
|
#include <vector>
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
|
|
|
|
struct Node {
|
|
|
|
std::list<int> neighbours;
|
|
|
|
|
|
|
|
Node() = default;
|
|
|
|
Node(std::list<int> neighbours);
|
|
|
|
void add_edge(int v);
|
2024-07-24 15:54:43 +02:00
|
|
|
int outdeg() const;
|
2024-07-14 16:44:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Digraph {
|
|
|
|
public:
|
|
|
|
Digraph(size_t num_nodes);
|
|
|
|
void add_edge(int from, int to);
|
|
|
|
std::list<int> adjList(int node_id) const;
|
|
|
|
size_t num_nodes() const;
|
|
|
|
Digraph transpose() const;
|
|
|
|
bool isEdge(int from, int to) const;
|
2024-07-24 15:54:43 +02:00
|
|
|
int outdeg(int v) const;
|
|
|
|
std::vector<int> indegrees() const;
|
2024-07-14 16:44:12 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::vector<Node> nodes;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //C___DIGRAPH_H
|
|
|
|
|
|
|
|
|