# `Graph.Edge`

This module defines the struct used to represent edges and associated metadata about them.

Used internally, `v1` and `v2` typically hold vertex ids, not the vertex itself, but all
public APIs which return `Graph.Edge` structs, return them with the actual vertices.

# `edge_opt`

```elixir
@type edge_opt() ::
  {:weight, integer() | float()} | {:label, term()} | {:properties, map()}
```

# `edge_opts`

```elixir
@type edge_opts() :: [edge_opt()]
```

# `t`

```elixir
@type t() :: %Graph.Edge{
  label: term(),
  properties: map(),
  v1: Graph.vertex(),
  v2: Graph.vertex(),
  weight: integer() | float()
}
```

# `new`

```elixir
@spec new(Graph.vertex(), Graph.vertex(), [edge_opt()]) :: t() | no_return()
```

Defines a new edge and accepts optional values for weight, label, and properties.

## Options

- `:weight` - the weight of the edge (integer or float, default: `1`)
- `:label` - the label for the edge (default: `nil`)
- `:properties` - an arbitrary map of additional metadata (default: `%{}`)

An error will be thrown if weight is not an integer or float.

## Examples

    iex> edge = Graph.Edge.new(:a, :b, label: :foo, weight: 2, properties: %{color: "red"})
    ...> {edge.label, edge.weight, edge.properties}
    {:foo, 2, %{color: "red"}}

    iex> Graph.new |> Graph.add_edge(Graph.Edge.new(:a, :b, weight: "1"))
    ** (ArgumentError) invalid value for :weight, must be an integer

---

*Consult [api-reference.md](api-reference.md) for complete listing*
