Defining pow functions for adjacency and transition matrices#463
Defining pow functions for adjacency and transition matrices#463wrcorcoran wants to merge 13 commits intoZigRazor:masterfrom
Conversation
| namespace CXXGraph { | ||
|
|
||
| template <typename T> | ||
| const PowAdjResult Graph<T>::powAdjMatrix(unsigned int k) const { |
There was a problem hiding this comment.
Why two specific methods? I think that one method overloaded two times would be better.
There was a problem hiding this comment.
Okay! I'll just have the user pass an enum value to distinguish. Or, would you prefer they pass the actual matrices themselves to the function? I just want to make sure I'm being consistent with the rest of the repo's style.
There was a problem hiding this comment.
virtual const PowAdjResult matrixPow(unsigned int k, AdjacencyMatrix adj) const
with usage like:
graph.matrixPow(2, graph.getAdjMatrix());
This feels wrong to me... should I make a function w/ is not a member of the CXXGraph class? That also feels wrong...
What kind of overloading are you thinking?
There was a problem hiding this comment.
Hi, sorry for the delay, I'm very busy these weeks. For me the best thing would be to implement them as free functions, not as Graph methods. But we can hear what @ZigRazor thinks.
There was a problem hiding this comment.
Hey @ZigRazor
Just following up here - would like to get this wrapped up soon! Thoughts on implementing this as a free function?
There was a problem hiding this comment.
Sorry for the delay.
Yes, the best choice for me is to implement them as a free functions.
Thank you
| std::vector<std::vector<T>> res(n, std::vector<T>(n, 0)); | ||
|
|
||
| // build identity matrix | ||
| for (int i = 0; i < n; i++) res[i][i] = 1; |
There was a problem hiding this comment.
I would use a standard algorithm for this, like std::transform, std::fill or std::generate
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #463 +/- ##
==========================================
+ Coverage 97.87% 97.89% +0.02%
==========================================
Files 87 89 +2
Lines 10079 10274 +195
Branches 670 687 +17
==========================================
+ Hits 9865 10058 +193
- Misses 214 216 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
@wrcorcoran this pull request seems good, but the workflow does not compile, can you check why? |
#455 - Define pow function for graph matrices
powAdjMatrixandpowTransitionMatrix, respectively).@ZigRazor @sbaldu