ReverseView and UndirectedView#376
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #376 +/- ##
==========================================
+ Coverage 97.27% 97.35% +0.07%
==========================================
Files 118 121 +3
Lines 6874 6992 +118
==========================================
+ Hits 6687 6807 +120
+ Misses 187 185 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@gdalle Should be good for review. Do you know what's wrong with the documentation? |
| struct ReverseView{T<:Integer,G<:AbstractGraph} <: AbstractGraph{T} | ||
| g::G | ||
|
|
||
| @traitfn ReverseView{T,G}(g::::(IsDirected)) where {T<:Integer,G<:AbstractGraph{T}} = | ||
| new(g) | ||
| @traitfn ReverseView{T,G}(g::::(!IsDirected)) where {T<:Integer,G<:AbstractGraph{T}} = | ||
| throw(ArgumentError("Your graph needs to be directed")) | ||
| end |
There was a problem hiding this comment.
Wouldn't it make more sense if this function works on all graphs? Even if it does nothing for undirected graphs.
| 1 | ||
| ``` | ||
| """ | ||
| struct UndirectedView{T<:Integer,G<:AbstractGraph} <: AbstractGraph{T} |
There was a problem hiding this comment.
Could we distinguish between weak and strong connectivity? I.e. weaks means that v and w in the undirected view are connected if either v -> w or v <- w in the original graph. Strong means that v <-> w in the original graph.
| """ | ||
| struct UndirectedView{T<:Integer,G<:AbstractGraph} <: AbstractGraph{T} | ||
| g::G | ||
| ne::Int |
There was a problem hiding this comment.
Precalculating ne is a bit dangerous as one might change the underlying graph and then the view would be invalid. If we cache this value then we should be very clear about that in the documentation.
I think it might be worth not to cache it and then make sure that all our algorithms calculate ne only once.
| @traitfn function UndirectedView{T,G}( | ||
| g::::(IsDirected) | ||
| ) where {T<:Integer,G<:AbstractGraph{T}} | ||
| ne = count(e -> src(e) <= dst(e) || !has_edge(g, dst(e), src(e)), Graphs.edges(g)) |
There was a problem hiding this comment.
| ne = count(e -> src(e) <= dst(e) || !has_edge(g, dst(e), src(e)), Graphs.edges(g)) | |
| ne = count(e -> src(e) <= dst(e) && src(e) <= dst(e), Graphs.edges(g)) |
This way we can avoid the expensive call to has_edge!
There was a problem hiding this comment.
This seems to be checking the same thing twice?
No description provided.