Skip to content

Fix ambiguity errors for integer vertices passed to degree #15

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

Merged
merged 1 commit into from
Jan 20, 2023
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
15 changes: 15 additions & 0 deletions src/abstractdatagraph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ for f in [
end
end

# Fix for ambiguity error with `AbstractGraph` version
function degree(graph::AbstractDataGraph, vertex::Integer)
return degree(underlying_graph(graph), vertex)
end

# Fix for ambiguity error with `AbstractGraph` version
function dijkstra_shortest_paths(graph::AbstractDataGraph, vertices::Vector{<:Integer})
return dijkstra_shortest_paths(underlying_graph(graph), vertices)
Expand All @@ -100,6 +105,16 @@ function eccentricity(graph::AbstractDataGraph, distmx::AbstractMatrix)
return eccentricity(underlying_graph(graph), distmx)
end

# Fix for ambiguity error with `AbstractGraph` version
function indegree(graph::AbstractDataGraph, vertex::Integer)
return indegree(underlying_graph(graph), vertex)
end

# Fix for ambiguity error with `AbstractGraph` version
function outdegree(graph::AbstractDataGraph, vertex::Integer)
return outdegree(underlying_graph(graph), vertex)
end

@traitfn directed_graph(graph::AbstractDataGraph::IsDirected) = graph

@traitfn function directed_graph(graph::AbstractDataGraph::(!IsDirected))
Expand Down
7 changes: 7 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ using Test
@test !isassigned(dg, 3)
@test !isassigned(dg, 4)

@test degree(g, 1) == 1
@test indegree(g, 1) == 1
@test outdegree(g, 1) == 1
@test degree(g, 2) == 2
@test indegree(g, 2) == 2
@test outdegree(g, 2) == 2

@test has_edge(dg, 1, 2)
@test has_edge(dg, 1 => 2)
@test !has_edge(dg, 1, 3)
Expand Down