Skip to content

Commit

Permalink
TropicalGeometry: tropical_linear_space from graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
YueRen committed Jan 24, 2025
1 parent 3e86180 commit 9079fd8
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/src/TropicalGeometry/linear_space.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ In addition to converting from `TropicalVariety`, objects of type `TropicalLinea
4. matrices over a field and a tropical semiring map.
- if matrix over `QQ` and tropical semiring map is trivial, uses an implementation of Rincon's algorithm [Rin13](@cite) in `polymake`
- for general input, computes minors and uses constructor (2.)
5. graphs
```@docs
tropical_linear_space
```
Expand Down
24 changes: 24 additions & 0 deletions src/TropicalGeometry/linear_space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,30 @@ function tropical_linear_space(I::MPolyIdeal, nu::Union{Nothing,TropicalSemiring
end


@doc raw"""
tropical_linear_space(G::Graph, nu::TropicalSemiringMap; weighted_polyhedral_complex_only::Bool=false)
Return the Bergman fan of the graphic matroid of `G` as a tropical linear space, the tropical semiring map `nu` is used to fix the convention. If `weighted_polyhedral_complex==true`, will not cache any extra information.
# Examples
```jldoctest
julia> G = complete_graph(4)
Undirected graph with 4 nodes and the following edges:
(2, 1)(3, 1)(3, 2)(4, 1)(4, 2)(4, 3)
julia> tropical_linear_space(G)
Min tropical linear space
```
"""
function tropical_linear_space(G::Graph, nu::Union{Nothing,TropicalSemiringMap}=nothing; weighted_polyhedral_complex_only::Bool=false)
M = matrix(QQ,signed_incidence_matrix(G))
TropG = tropical_linear_space(M,nu;weighted_polyhedral_complex_only=weighted_polyhedral_complex_only)
if !weighted_polyhedral_complex_only
set_attribute!(TropG,:graph,G)
end
return TropG
end

###############################################################################
#
Expand Down
6 changes: 6 additions & 0 deletions test/TropicalGeometry/linear_space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,10 @@
@test issetequal(plueckerVector,tropical_pluecker_vector(TropL))
end

@testset "tropical linear space from graphs" begin
G = complete_graph(3)
TropG = tropical_linear_space(G)
@test f_vector(TropG) == [0,1,3]
end

end

0 comments on commit 9079fd8

Please sign in to comment.