Logo
No results found.
DirectedGraph
Overview

DirectedGraph

July 30, 2024
1 min read

用途

重み付き有向グラフを扱う.

使い方

宣言

DirectedGraph g(n);

重み付き有向パスの追加

g.add(パス始点, パス終点, 重み);

実装

class DirectedGraph {
public:
struct Edge {
int to, cost;
};
const int n;
vector<vector<Edge>> g;
DirectedGraph(int _n) : n(_n), g(_n) {}
void add(int s, int t, int cost) {
g[s].push_back({t, cost});
}
};

Depended on

Downloading for offline use...