ja / en
Overview

DirectedGraph

2024/07/30
1 min read

Purpose

Handles weighted directed graphs.

Usage

Declaration

DirectedGraph g(n);

Add weighted directed edge

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

Implementation

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