Skip to content

Commit 69551de

Browse files
committed
TropicalGeometry: tropical_linear_space from graphs
1 parent e36a504 commit 69551de

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

docs/src/TropicalGeometry/linear_space.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ In addition to converting from `TropicalVariety`, objects of type `TropicalLinea
1818
4. matrices over a field and a tropical semiring map.
1919
- if matrix over `QQ` and tropical semiring map is trivial, uses an implementation of Rincon's algorithm [Rin13](@cite) in `polymake`
2020
- for general input, computes minors and uses constructor (2.)
21+
5. graphs
2122
```@docs
2223
tropical_linear_space
2324
```

src/TropicalGeometry/linear_space.jl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,30 @@ function tropical_linear_space(I::MPolyIdeal, nu::Union{Nothing,TropicalSemiring
365365
end
366366

367367

368+
@doc raw"""
369+
tropical_linear_space(G::Graph, nu::TropicalSemiringMap; weighted_polyhedral_complex_only::Bool=false)
370+
371+
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.
372+
373+
# Examples
374+
```jldoctest
375+
julia> G = complete_graph(4)
376+
Undirected graph with 4 nodes and the following edges:
377+
(2, 1)(3, 1)(3, 2)(4, 1)(4, 2)(4, 3)
378+
379+
julia> tropical_linear_space(G)
380+
Min tropical linear space
381+
382+
```
383+
"""
384+
function tropical_linear_space(G::Graph, nu::Union{Nothing,TropicalSemiringMap}=nothing; weighted_polyhedral_complex_only::Bool=false)
385+
M = matrix(QQ,signed_incidence_matrix(G))
386+
TropG = tropical_linear_space(M,nu;weighted_polyhedral_complex_only=weighted_polyhedral_complex_only)
387+
if !weighted_polyhedral_complex_only
388+
set_attribute!(TropG,:graph,G)
389+
end
390+
return TropG
391+
end
368392

369393
###############################################################################
370394
#

test/TropicalGeometry/linear_space.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@
3232
@test issetequal(plueckerVector,tropical_pluecker_vector(TropL))
3333
end
3434

35+
@testset "tropical linear space from graphs" begin
36+
G = complete_graph(3)
37+
TropG = tropical_linear_space(G)
38+
@test f_vector(TropG) == [0,1,3]
39+
end
40+
3541
end

0 commit comments

Comments
 (0)