-
Notifications
You must be signed in to change notification settings - Fork 222
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
Add difub for computing the diameter of directed strongly connected networks #791
base: master
Are you sure you want to change the base?
Conversation
Right now difub takes the largest scc of a graph since getting directed strongly connected graphs is difficult.
networkit/cpp/distance/Diameter.cpp
Outdated
count size_f = i < distancesF.size() ? distancesF[i].size() : 0; | ||
count size_b = i < distancesB.size() ? distancesB[i].size() : 0; | ||
#pragma omp parallel for | ||
for (count j = 0; j < size_f + size_b; ++j) { |
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.
This needs to be omp_index
which is a signed integer when using MSVC as - at lest with the parameters NetworKit uses - MSVC doesn't support OpenMP loops with unsigned integers.
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.
Thanks, I fixed it. Changing j
to omp_index
should be enough? In cpp/distance/APSP.cpp
the loop has a count
in its condition.
Master branch seems to pass CI now, merged it and now this branch should pass it as well. |
@@ -37,7 +37,7 @@ auto callBFSHandle(F &f, node u, count) -> decltype(f(u)) { | |||
* @param handle Takes a node as input parameter. | |||
*/ | |||
template <class InputIt, typename L> | |||
void BFSfrom(const Graph &G, InputIt first, InputIt last, L handle) { | |||
void BFSfrom(const Graph &G, InputIt first, InputIt last, L handle, bool reverse = false) { |
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.
Thank you for the PR. I see that you need to follow in-edges but I am not sure that adding this reverse
parameter to BFSfrom
is the best way to do it.
What about making the implementation of BFSfrom private (e.g., BFSfromImpl
) and exposing two functions BFSfrom
(follows out-edges) and ReverseBFSfrom
(follows in-edges)? The two functions would both use BFSfromImpl
, which can take an additional (template?) boolean parameter to decide whether to follow in- our out-edges (as you are already doing here). This holds for Eccentricity
as well.
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.
Thank you for the feedback. This sounds like a good way to do it. I will implement it like this.
Compute the diameter of directed graphs with one strongly connected component faster than with the current naive approach.
Implemented as the practical part of @michitux lecture on networks.
Difub: http://link.springer.com/chapter/10.1007/978-3-642-30850-5_10