Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ Documentation for [GraphProperties](https://github.com/JuliaGraphs/GraphProperti

```@docs
GraphProperty
graph_property_type
PropertyComparison
```

```@autodocs
Modules = [GraphProperties]
Filter = !(t -> t in (GraphProperty, PropertyComparison))
Filter = !(t -> t in (GraphProperty, graph_property_type, PropertyComparison))
```
12 changes: 12 additions & 0 deletions src/GraphProperties.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module GraphProperties

export
GraphProperty,
graph_property_type,
PropertyComparison

"""
Expand All @@ -13,6 +14,17 @@ The only type parameter is the type of each value of the property.
"""
abstract type GraphProperty{T} end

"""
graph_property_type(::GraphProperty{T}) -> T

Get the type of each value of the property.

It is not allowed to add methods to this function.
"""
function graph_property_type(::GraphProperty{T}) where {T}
T
end

"""
PropertyComparison(comparison, property, value)

Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ using Test
@test FractionalChromaticNumber() isa GraphProperty{Real}
@test DegreeSequence() isa GraphProperty{AbstractVector{<:Integer}}
end
@testset "`graph_property_type`" begin
@test Bool === @inferred graph_property_type(GraphIsCograph())
@test Integer === @inferred graph_property_type(Degeneracy())
@test Real === @inferred graph_property_type(Strength())
@test AbstractVector{<:Integer} == @inferred graph_property_type(DegreeSequence())
end
end

using Aqua: Aqua
Expand Down