Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Implementing the is_directed trait correctly #591

Closed
rohitvarkey opened this issue Apr 12, 2017 · 4 comments
Closed

Implementing the is_directed trait correctly #591

rohitvarkey opened this issue Apr 12, 2017 · 4 comments

Comments

@rohitvarkey
Copy link
Contributor

I've been trying to get the abstraction to LightGraphs working with an AbstractGraph. But I've have not been able to get the is_directed trait to work. I was following the example from the SimpleDiGraphs implementation. I keep getting an Not Implemented error.

This is an minimal example of the error.

julia> import LightGraphs: AbstractGraph, is_directed

julia> struct LGTest <: AbstractGraph
           g::Int64
       end

julia> is_directed(::LGTest) = true
is_directed (generic function with 8 methods)

julia> is_directed(::Type{LGTest}) = true
is_directed (generic function with 9 methods)

julia> LightGraphs.maximal_cliques(LGTest(15))
ERROR: Not implemented: is_directed
Stacktrace:
 [1] is_directed(::Type{LGTest}) at /Users/rohitvarkey/.julia/v0.6/LightGraphs/src/interface.jl:116
 [2] trait(...) at /Users/rohitvarkey/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:186
 [3] maximal_cliques(::LGTest) at /Users/rohitvarkey/.julia/v0.6/SimpleTraits/src/SimpleTraits.jl:319

Is this the correct way of implementing the is_directed trait?

@sbromberger
Copy link
Owner

sbromberger commented Apr 12, 2017

That's non-intuitive. Paging @mauro3 for some assistance here.

Relevant lines from interface.jl:

abstract type AbstractGraph end
@traitdef IsDirected{G<:AbstractGraph}
@traitimpl IsDirected{G} <- is_directed(G)
is_directed(x...) = _NI("is_directed")
is_directed{T}(::Type{T}) = _NI("is_directed")

@sbromberger
Copy link
Owner

see JuliaLang/julia#21356 and mauro3/SimpleTraits.jl#38 as possibly related.

@mauro3
Copy link

mauro3 commented Apr 18, 2017

Let's re-check this after the fix of mauro3/SimpleTraits.jl#39, which should hopefully be done very soon.

@sbromberger
Copy link
Owner

Closing as fixed via mauro3/SimpleTraits.jl#41.

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants