Skip to content

Commit

Permalink
Combinatorics: Print graphs nicely
Browse files Browse the repository at this point in the history
  • Loading branch information
lkastner committed Sep 11, 2023
1 parent 5756189 commit b0120b9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Combinatorics/Graphs/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1051,3 +1051,24 @@ Polyhedron in ambient dimension 6
```
"""
fractional_matching_polytope(G::Graph{Undirected}) = polyhedron(Polymake.polytope.fractional_matching_polytope(pm_object(G)))


################################################################################
################################################################################
## Printing
################################################################################
################################################################################
function Base.show(io::IO, ::MIME"text/plain", G::Graph{T}) where {T <: Union{Polymake.Directed, Polymake.Undirected}}
println(io, "Graph{$T} with the following edges:") # at least one new line is needed
for e in edges(G)
print(io, "($(src(e)), $(dst(e)))")
end
end

function Base.show(io::IO, G::Graph{T}) where {T <: Union{Polymake.Directed, Polymake.Undirected}}
if get(io, :supercompact, false)
print(io, "Graph{$T}")
else
print(io, "Graph{$T} with $(nvertices(G)) nodes and $(nedges(G)) edges")
end
end

0 comments on commit b0120b9

Please sign in to comment.