# Curves

## Introduction

An *abstract tropical curve* is a finite, loopless, multigraph. It is defined by an incidence matrix with vertices as columns and edges as rows.

A *divisor* on an abstract tropical curve is a formal linear combination of the vertices with integer coefficients. The degree of a divisor is the sum of its coefficients. A divisor is effective if all its coefficients are nonnegative.

For more definitions on the theory of divisors and linear sisyems on abstract tropical curve, we refer to Matthew Baker, Serguei Norine (2007).

The *tropical Jacobian* of an abstract tropical curve is the group of divisors of degree zero modulo the subgroup of principal divisors. Here a principal divisor is the divisor associated to a piecewise-linear function on the vertices by the Laplacian operator. The tropical Jacobian is a finite abelian group, with order equal to the number of maximal spanning trees in the graph. It is isomorphic to $\prod{\mathbb{Z}/n_{i}\mathbb{Z}}$, where the $n_{i}$ are the nonzero elementary divisors of the Laplacian matrix. For more details, see Matthew Baker, Serguei Norine (2007).

## Construction

`TropicalCurve`

— Method`TropicalCurve(PC::PolyhedralComplex)`

Construct a tropical curve from a polyhedral complex. If the curve is embedded, vertices must are points in $\mathbb R^n$. If the curve is abstract, the polyhedral complex is empty, vertices must be 1, ..., n, and the graph is given as attribute.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4]])
3×4 IncidenceMatrix
[1, 2]
[1, 3]
[1, 4]
julia> VR = [0 0; 1 0; -1 0; 0 1]
4×2 Matrix{Int64}:
0 0
1 0
-1 0
0 1
julia> PC = polyhedral_complex(QQFieldElem, IM, VR)
Polyhedral complex in ambient dimension 2
julia> TC = TropicalCurve(PC)
min tropical curve in 2-dimensional Euclidean space
julia> abs_TC = TropicalCurve(IM)
Abstract min tropical curve
```

`DivisorOnTropicalCurve`

— Method`DivisorOnTropicalCurve(tc::TropicalCurve, coeffs::Vector{Int})`

Construct a divisor with coefficients `coeffs`

on an abstract tropical curve `tc`

.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
```

## Auxiliary functions

`graph`

— Method`graph(tc::TropicalCurve)`

Return the graph of an abstract tropical curve `tc`

.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> graph(tc)
6×4 IncidenceMatrix
[1, 2]
[1, 3]
[1, 4]
[2, 3]
[2, 4]
[3, 4]
```

`n_nodes`

— Method`n_nodes(tc::TropicalCurve)`

Return the number of nodes of an abstract tropical curve `tc`

.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> n_nodes(tc)
4
```

`coefficients`

— Method`coefficients(dtc::DivisorOnTropicalCurve)`

Construct a divisor `dtc`

with coefficients `coeffs`

on an abstract tropical curve.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> coefficients(dtc)
4-element Vector{Int64}:
0
1
1
1
```

`degree`

— Methoddegree(dtc::DivisorOnTropicalCurve)

Compute the degree of a divisor `dtc`

on an abstract tropical curve.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> degree(dtc)
3
```

`is_effective`

— Method`is_effective(dtc::DivisorOnTropicalCurve)`

Check whether a divisor `dtc`

on an abstract tropical curve is effective.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> is_effective(dtc)
true
```

`chip_firing_move`

— Methodchip*firing*move(dtc::DivisorOnTropicalCurve, position::Int)

Given a divisor `dtc`

and vertex labelled `position`

, compute the linearly equivalent divisor obtained by a chip firing move from the given vertex `position`

.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> chip_firing_move(dtc,1)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [-3, 2, 2, 2])
```

`v_reduced`

— Methodv_reduced(dtc::DivisorOnTropicalCurve, vertex::Int)

Given a divisor `dtc`

and vertex labelled `vertex`

, compute the unique divisor reduced with repspect to `vertex`

as defined in Matthew Baker, Serguei Norine (2007). The divisor `dtc`

must have positive coefficients apart from `vertex`

.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs = [0, 1, 1, 1];
julia> dtc = DivisorOnTropicalCurve(tc,coeffs)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> v_reduced(dtc,1)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [3, 0, 0, 0])
```

`is_linearly_equivalent`

— Methodis*linearly*equivalent(dtc1::DivisorOnTropicalCurve, dtc2::DivisorOnTropicalCurve)

Given two effective divisors `dtc1`

and `dtc2`

on the same tropical curve, check whether they are linearly equivalent.

**Examples**

```
julia> IM = IncidenceMatrix([[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]);
julia> tc = TropicalCurve(IM)
Abstract min tropical curve
julia> coeffs1 = [0, 1, 1, 1];
julia> dtc1 = DivisorOnTropicalCurve(tc,coeffs1)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [0, 1, 1, 1])
julia> coeffs2 = [3,0,0,0];
julia> dtc2 = DivisorOnTropicalCurve(tc,coeffs2)
DivisorOnTropicalCurve{min, false}(Abstract min tropical curve, [3, 0, 0, 0])
julia> is_linearly_equivalent(dtc1, dtc2)
true
```

`structure_tropical_jacobian`

— Method`structure_tropical_jacobian(TC::TropicalCurve)`

Compute the elementary divisors $n_i$ of the Laplacian matrix of the tropical curve `TC`

. The tropical Jacobian is then isomorphic to $\prod (Z/(n_i)Z)$.

**Examples**

```
julia> cg = complete_graph(5);
julia> IM1=IncidenceMatrix([[src(e), dst(e)] for e in edges(cg)])
10×5 IncidenceMatrix
[1, 2]
[1, 3]
[2, 3]
[1, 4]
[2, 4]
[3, 4]
[1, 5]
[2, 5]
[3, 5]
[4, 5]
julia> TC1 = TropicalCurve(IM1)
Abstract min tropical curve
julia> structure_tropical_jacobian(TC1)
(General) abelian group with relation matrix
[1 0 0 0; 0 5 0 0; 0 0 5 0; 0 0 0 5]
julia> cg2 = complete_graph(3);
julia> IM2=IncidenceMatrix([[src(e), dst(e)] for e in edges(cg2)])
3×3 IncidenceMatrix
[1, 2]
[1, 3]
[2, 3]
julia> TC2 = TropicalCurve(IM2)
Abstract min tropical curve
julia> structure_tropical_jacobian(TC2)
(General) abelian group with relation matrix
[1 0; 0 3]
julia> IM3 = IncidenceMatrix([[1,2],[2,3],[3,4],[4,5],[1,5]])
5×5 IncidenceMatrix
[1, 2]
[2, 3]
[3, 4]
[4, 5]
[1, 5]
julia> TC3=TropicalCurve(IM3)
Abstract min tropical curve
julia> G = structure_tropical_jacobian(TC3)
(General) abelian group with relation matrix
[1 0 0 0; 0 1 0 0; 0 0 1 0; 0 0 0 5]
```