Skip to content

Commit

Permalink
make clipboard(g) work (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
anandijain committed May 30, 2022
1 parent 13247a4 commit 7152d54
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/SimpleGraphs/SimpleGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ An abstract type representing a simple graph structure.
"""
abstract type AbstractSimpleGraph{T<:Integer} <: AbstractGraph{T} end

function show(io::IO, g::AbstractSimpleGraph{T}) where T
function show(io::IO, ::MIME"text/plain", g::AbstractSimpleGraph{T}) where T
dir = is_directed(g) ? "directed" : "undirected"
print(io, "{$(nv(g)), $(ne(g))} $dir simple $T graph")
end
Expand Down
10 changes: 6 additions & 4 deletions test/simplegraphs/simplegraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,18 @@ import Random
gx = SimpleGraph()
for g in testgraphs(gx)
T = eltype(g)
@test sprint(show, g) == "{0, 0} undirected simple $T graph"
@test repr("text/plain", g) == "{0, 0} undirected simple $T graph"
@test @inferred(add_vertices!(g, 5) == 5)
@test sprint(show, g) == "{5, 0} undirected simple $T graph"
@test repr("text/plain", g) == "{5, 0} undirected simple $T graph"
@test eval(Meta.parse(repr(g))) == g
end
gx = SimpleDiGraph()
for g in testdigraphs(gx)
T = eltype(g)
@test sprint(show, g) == "{0, 0} directed simple $T graph"
@test repr("text/plain", g) == "{0, 0} directed simple $T graph"
@test @inferred(add_vertices!(g, 5) == 5)
@test sprint(show, g) == "{5, 0} directed simple $T graph"
@test repr("text/plain", g) == "{5, 0} directed simple $T graph"
@test eval(Meta.parse(repr(g))) == g
end

gx = path_graph(4)
Expand Down

0 comments on commit 7152d54

Please sign in to comment.