From aeb165243b20b0945d01b3c0d540dbc969526a99 Mon Sep 17 00:00:00 2001 From: Seth Bromberger Date: Wed, 22 Aug 2018 08:47:11 -0700 Subject: [PATCH] SimpleGraph(SimpleGraph) plus tests. (#998) --- src/SimpleGraphs/simplegraph.jl | 3 +++ test/simplegraphs/simplegraphs.jl | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/SimpleGraphs/simplegraph.jl b/src/SimpleGraphs/simplegraph.jl index 0abb6003f..05f7dbc0e 100644 --- a/src/SimpleGraphs/simplegraph.jl +++ b/src/SimpleGraphs/simplegraph.jl @@ -21,6 +21,9 @@ end # SimpleGraph() SimpleGraph() = SimpleGraph{Int}() +# SimpleGraph of a SimpleGraph +SimpleGraph(g::SimpleGraph) = copy(g) + # SimpleGraph(6), SimpleGraph(0x5) SimpleGraph(n::T) where T <: Integer = SimpleGraph{T}(n) diff --git a/test/simplegraphs/simplegraphs.jl b/test/simplegraphs/simplegraphs.jl index 2f4523c26..625b66831 100644 --- a/test/simplegraphs/simplegraphs.jl +++ b/test/simplegraphs/simplegraphs.jl @@ -166,6 +166,16 @@ import Random @test @inferred(has_edge(g, e)) end + gx = CompleteGraph(4) + for g in testgraphs(gx) + h = Graph(g) + @test g == h + @test rem_vertex!(g, 2) + @test nv(g) == 3 && ne(g) == 3 + @test g != h + end + + gdx = CompleteDiGraph(4) for g in testdigraphs(gdx) h = DiGraph(g)