Skip to content
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

period function does not work correctly for abstract directed graphs #89

Closed
simonschoelly opened this issue Jan 9, 2022 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@simonschoelly
Copy link
Member

Currently the period functions seems to work only for SimpleDiGraph. It should either be restricted to that type or implemented in a way that works with other directed AbstractGraph.

How to reproduce:

julia> using Graphs, SimpleWeightedGraphs

julia> g = cycle_digraph(4)
{4, 4} directed simple Int64 graph

julia> gw = SimpleWeightedDiGraph(g)
{4, 4} directed simple Int64 graph with Float64 weights

julia> period(g)
4

julia> period(gw)
ERROR: MethodError: no method matching difference(::SimpleWeightedDiGraph{Int64, Float64}, ::SimpleDiGraph{Int64})
Closest candidates are:
  difference(::T, ::T) where T<:AbstractGraph at ~/.julia/dev/Graphs/src/operators.jl:196
Stacktrace:
 [1] period(::Type{IsDirected{SimpleWeightedDiGraph{Int64, Float64}}}, g::SimpleWeightedDiGraph{Int64, Float64})
   @ Graphs ~/.julia/dev/Graphs/src/connectivity.jl:503
 [2] period(g::SimpleWeightedDiGraph{Int64, Float64})
   @ Graphs ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:331
 [3] top-level scope
   @ REPL[20]:1
@simonschoelly simonschoelly added the bug Something isn't working label Jan 9, 2022
etiennedeg added a commit to etiennedeg/Graphs.jl that referenced this issue Jan 10, 2022
etiennedeg added a commit to etiennedeg/Graphs.jl that referenced this issue Jan 10, 2022
etiennedeg added a commit to etiennedeg/Graphs.jl that referenced this issue Jan 10, 2022
@etiennedeg
Copy link
Member

I think difference should not be defined for AbstractGraph

@simonschoelly
Copy link
Member Author

Yes, these operator functions such as difference is also something we have to deal with in the future. Maybe it would be possible to implement Period without relaying on difference.

@etiennedeg
Copy link
Member

I just made a PR doing this. This will even be more performant, as we don't need to allocate a new graph.

@simonschoelly
Copy link
Member Author

Fixed by #90

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants