C++ Competitive ProgrammingDirectedGraphromophic-library用途重み付き有向グラフを扱う.使い方宣言1 DirectedGraph g(n); 重み付き有向パスの追加1 g.add(パス始点, パス終点, 重み); 実装 1 2 3 4 5 6 7 8 9 10 11 12 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 onWarshallFloydDijkstraBellmanFordTopologicalSortgetFarthestVertex(最遠頂点を求める)