Skip to content

Commit

Permalink
Conversion from GenericGraph to SImpleGraph
Browse files Browse the repository at this point in the history
  • Loading branch information
gdalle committed Feb 7, 2024
1 parent b158054 commit 3ff0588
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Test/Test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ function generic_graph(g::Union{SimpleGraph,SimpleDiGraph})
return is_directed(g) ? GenericDiGraph(g) : GenericGraph(g)
end

# ensure type stability in conversion
Graphs.Graph(g::Union{GenericGraph,GenericDiGraph}) = Graph(g.g)
Graphs.DiGraph(g::Union{GenericGraph,GenericDiGraph}) = DiGraph(g.g)

function GenericDiGraph(elist::Vector{Graphs.SimpleDiGraphEdge{T}}) where {T<:Integer}
return GenericDiGraph{T}(SimpleDiGraph(elist))
end
Expand Down

0 comments on commit 3ff0588

Please sign in to comment.