-
Notifications
You must be signed in to change notification settings - Fork 0
Add dinic #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
写経をしやすいようにするライブラリなのに(int)などのキャストをstatic_cast()にしないといけないのはどうなのかなと思いました. |
|
./lib/Graph/dinic.cpp:28: Using C-style cast. Use static_cast(...) instead [readability/casting] [4] |
なるほど |
lib/Graph/dinic.cpp
Outdated
vector<T> minCost; | ||
vector<int> iter; | ||
vector<vector<Edge<T>>> graph; | ||
const T INF = numeric_limits<T>::max(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFに最大値をそのまま使うのは、1以上の数字を足した時にオーバーフローするので良くないとされています(蟻本の最初の方のINFが初登場するらへんに書いてたはず)
なので、最大値を10割った値ぐらいに設定する必要があります
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど.それは意識していませんでした.10で割った数に変えます
0エラーというのはstatic_castを外した状態で起きているのですか? |
|
lib/Graph/dinic.cpp
Outdated
template <typename T> | ||
T Dinic<T>::Dfs(int idx, const int t, T flow) { | ||
if (idx == t) return flow; | ||
for (int &i = iter[idx]; i < static_cast<int>(graph[idx].size()); ++i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここの static_cast
はなくてもエラーにならないと思います
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
確かに大丈夫でした.修正します
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
良さそうなのでマージお願いします
(僕がマージするより本人にしてもらうほうが良いと気付いた)
Dinicクラスを実装しました.