This documentation is automatically generated by online-judge-tools/verification-helper
#include "cpp/graph/bellman_ford.hpp"#pragma once
#include "graph/graph_list.hpp"
#include "template/small_template.hpp"
/**
* ベルマンフォード法
* 有向グラフの単一始点最短経路 O(EV)
* 到達不能:max, 負閉路を通る:min
* https://mhrb-minase.hatenablog.com/entry/2019/08/20/003915
*/
template <class Cost, class E>
void ListGraph<Cost, E>::bellman_ford(int start_node) {
if (shortest_path_dist.count(start_node)) {
return;
}
vector<Cost> dist(n_, ListGraph::UNREACHABLE);
vector<int> parent(n_, -1);
dist[start_node] = 0;
for (int i = 0; i < n_ - 1; ++i) {
for (auto &es : adj) {
for (auto &e : es) {
if (dist[e.from] != ListGraph::UNREACHABLE &&
dist[e.from] + e.cost < dist[e.to]) {
dist[e.to] = dist[e.from] + e.cost;
parent[e.to] = e.from;
}
}
}
}
for (int i = 0; i < n_; ++i) {
for (auto &es : adj) {
for (auto &e : es) {
if (dist[e.from] != ListGraph::UNREACHABLE &&
dist[e.from] + e.cost < dist[e.to]) {
dist[e.to] = ListGraph::NEGATIVE_CYCLE;
parent[e.to] = -1;
}
}
}
}
shortest_path_dist[start_node] = std::move(dist);
shortest_path_parent[start_node] = std::move(parent);
}Traceback (most recent call last):
File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/documentation/build.py", line 71, in _render_source_code_stat
bundled_code = language.bundle(stat.path, basedir=basedir, options={'include_paths': [basedir]}).decode()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus.py", line 187, in bundle
bundler.update(path)
File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 401, in update
self.update(self._resolve(pathlib.Path(included), included_from=path))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/hostedtoolcache/Python/3.12.0/x64/lib/python3.12/site-packages/onlinejudge_verify/languages/cplusplus_bundle.py", line 260, in _resolve
raise BundleErrorAt(path, -1, "no such header")
onlinejudge_verify.languages.cplusplus_bundle.BundleErrorAt: graph/graph_list.hpp: line -1: no such header