# `LiveFlow.Edge`
[🔗](https://github.com/rocket4ce/live_flow/blob/main/lib/live_flow/core/edge.ex#L1)

Edge data structure for LiveFlow.

An edge represents a connection between two nodes, from a source
node's handle to a target node's handle.

## Fields

  * `:id` - Unique identifier for the edge (required)
  * `:source` - Source node ID (required)
  * `:target` - Target node ID (required)
  * `:source_handle` - Source handle ID (optional)
  * `:target_handle` - Target handle ID (optional)
  * `:type` - Edge type: `:bezier`, `:straight`, `:step`, `:smoothstep`
  * `:animated` - Whether to show animation on the edge
  * `:selected` - Whether the edge is currently selected
  * `:selectable` - Whether the edge can be selected
  * `:deletable` - Whether the edge can be deleted
  * `:hidden` - Whether the edge is visible
  * `:data` - Custom data map
  * `:label` - Edge label text
  * `:label_position` - Position of label along edge (0.0 to 1.0)
  * `:label_style` - Custom styles for label
  * `:marker_start` - Marker at start of edge
  * `:marker_end` - Marker at end of edge
  * `:style` - Custom inline styles
  * `:class` - Custom CSS classes
  * `:z_index` - Stacking order
  * `:interaction_width` - Clickable width for selection
  * `:path_options` - Additional options for path calculation

## Examples

    iex> LiveFlow.Edge.new("e1", "node-1", "node-2")
    %LiveFlow.Edge{id: "e1", source: "node-1", target: "node-2"}

    iex> LiveFlow.Edge.new("e2", "a", "b", type: :straight, animated: true)
    %LiveFlow.Edge{id: "e2", source: "a", target: "b", type: :straight, animated: true}

# `t`

```elixir
@type t() :: %LiveFlow.Edge{
  animated: boolean(),
  class: String.t() | nil,
  data: map(),
  deletable: boolean(),
  hidden: boolean(),
  id: String.t(),
  interaction_width: integer(),
  label: String.t() | nil,
  label_position: float(),
  label_style: map(),
  marker_end: map() | nil,
  marker_start: map() | nil,
  path_options: map(),
  reconnectable: boolean(),
  selectable: boolean(),
  selected: boolean(),
  source: String.t(),
  source_floating: boolean(),
  source_handle: String.t() | nil,
  style: map(),
  target: String.t(),
  target_floating: boolean(),
  target_handle: String.t() | nil,
  type: atom(),
  z_index: integer()
}
```

# `animate`

```elixir
@spec animate(t(), boolean()) :: t()
```

Sets the edge's animated state.

# `connects_same_nodes?`

```elixir
@spec connects_same_nodes?(t(), t()) :: boolean()
```

Checks if two edges connect the same nodes (ignoring direction).

# `connects_to?`

```elixir
@spec connects_to?(t(), String.t()) :: boolean()
```

Checks if an edge connects to a specific node (either as source or target).

# `effective_source_handle`

```elixir
@spec effective_source_handle(t()) :: String.t()
```

Gets the effective source handle ID.

# `effective_target_handle`

```elixir
@spec effective_target_handle(t()) :: String.t()
```

Gets the effective target handle ID.

# `new`

```elixir
@spec new(String.t(), String.t(), String.t(), keyword()) :: t()
```

Creates a new edge between source and target nodes.

## Options

  * `:source_handle` - Source handle ID
  * `:target_handle` - Target handle ID
  * `:type` - Edge type (default: `:bezier`)
  * `:animated` - Whether animated (default: `false`)
  * `:selectable` - Whether selectable (default: `true`)
  * `:deletable` - Whether deletable (default: `true`)
  * `:label` - Edge label text
  * `:marker_end` - End marker config (default: `%{type: :arrow}`)
  * `:marker_start` - Start marker config
  * `:style` - Custom inline styles
  * `:class` - Custom CSS classes
  * `:z_index` - Stacking order
  * `:data` - Custom data map

## Examples

    iex> LiveFlow.Edge.new("1", "a", "b")
    %LiveFlow.Edge{id: "1", source: "a", target: "b"}

    iex> LiveFlow.Edge.new("2", "a", "b", source_handle: "out", target_handle: "in")
    %LiveFlow.Edge{id: "2", source: "a", target: "b", source_handle: "out", target_handle: "in"}

# `select`

```elixir
@spec select(t(), boolean()) :: t()
```

Sets the edge's selected state.

# `set_label`

```elixir
@spec set_label(t(), String.t() | nil) :: t()
```

Sets the edge label.

# `update`

```elixir
@spec update(t(), keyword()) :: t()
```

Updates an edge with the given attributes.

---

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