Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TropicalGeometry: tropical linear spaces from graphs #4445

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
28 changes: 28 additions & 0 deletions src/TropicalGeometry/linear_space.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,34 @@ 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 = zero_matrix(QQ,nv(G),ne(G))
for (i,edge) in enumerate(edges(G))
M[src(edge),i] = 1
M[dst(edge),i] = -1
end
Comment on lines +385 to +389
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have signed_incidence_matrix. Could you maybe use that here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

signed_incidence_matrix only works for directed graphs. What I have is an undirected graph and I need the signed incidence matrix for a choice of directions (the choice does not matter).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's still something worth putting in its own function for people to use. I don't know if polymake has an acessor for that as well or if this would need your simple loop. Maybe @benlorenz or @lkastner can help out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, this is actually one of the changes of the Durham workshop that I am preparing right now.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once #4450 is merged, I am happy to update it.

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
Loading