-
Notifications
You must be signed in to change notification settings - Fork 19
Strong components #324
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
base: main
Are you sure you want to change the base?
Strong components #324
Conversation
2491366 to
bd124f8
Compare
bd124f8 to
2dd94ef
Compare
|
Thanks so much @harrysroberts , this looks great. I'll be back in my office next week, and will give it a run then. Just one comment in the meantime: Lots of lines in the PR are just formating/lint modifications. Could you please revert these, to remove all the line changes like changing |
|
Hi @mpadge , I've made those formatting adjustments, I thought I'd spotted all of those but I suppose it does it automatically if you don't have |
|
@harrysroberts Checks are failing because you need to update the docs with the new |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #324 +/- ##
==========================================
- Coverage 93.71% 93.01% -0.71%
==========================================
Files 52 52
Lines 6940 6768 -172
==========================================
- Hits 6504 6295 -209
- Misses 436 473 +37 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@harrysroberts Can you also please:
Thanks! |
Added Harry Roberts as a contributor.
|
@mpadge Done as requested |
This change adds additional functionality to the dodgr_components() function, where a new Boolean flag
strongwill cause the function to find the strong components of a directed graph. Thus, the partition of the graph into maximal subgraphs in which, for each pair of vertices i and j, paths exist both from i to j and from j to i. This is discussed further in Issue #322 .The main addition is to
graph.cpp, in which new functionsidentify_graph_strong_componentsand its recursive helperstrong_connectimplement Tarjan's strongly connected components algorithm.The format of the output of this algorithm, in comparison to the weak version, necessitated some minor adjustments to higher-level functions.
Firstly, within
rcpp_get_component_vector, the mapping of component numbers to edges has been adjusted such that an edge is always assigned the component of its start node.For the weak algorithm, this won't have any effect, as both start and end node are necessarily in the same component. However, for the strong algorithm this is not always the case, so edges that cross between strong components are (arbitrarily) assigned consistently to that of the start node.
Secondly, within the R function
dodgr_components, the assignment of component numbers in descending order is adjusted to use the frequencies when sorting.As the strong algorithm may result in components with no edges (i.e. individual nodes with no outbound edges), some numbers will be missed in the component table, resulting in an incorrect assignment of components. Using frequencies resolves this error.
Other changes to graph-functions.R, graph.h and graph.cpp were to insert the Boolean flag
strongto the necessary functions, ensuring that it defaults toFALSEso as to be compatible with existing code.