# `Clarity.Graph.Filter`
[🔗](https://github.com/team-alembic/clarity/blob/v0.5.1/lib/clarity/graph/filter.ex#L1)

Composable filter functions for graph vertices.

Filters are higher-order functions that take a graph for preparation
and return a predicate function that can be called for each vertex.

## Example Usage

    # Single filter
    subgraph = Graph.filter(graph, Filter.within_steps(vertex, 2, 1))

    # Composed filters
    filters = [
      Filter.within_steps(vertex, 2, 1),
      Filter.reachable_from(root_vertex),
      Filter.custom(fn v -> String.contains?(Vertex.name(v), "MyApp") end)
    ]
    subgraph = Graph.filter(graph, filters)

# `filter`

```elixir
@type filter() :: Clarity.Graph.query() | (Clarity.Graph.t() -&gt; Clarity.Graph.query())
```

# `all`

```elixir
@spec all([filter()]) :: filter()
```

Combines multiple filters using AND logic.

A vertex must pass ALL filters to be included in the result.

## Examples

    Filter.all([
      Filter.within_steps(vertex, 2, 0),
      Filter.vertex_type([Module])
    ])

# `any`

```elixir
@spec any([filter()]) :: filter()
```

Combines multiple filters using OR logic.

A vertex must pass ANY of the filters to be included in the result.

## Examples

    Filter.any([
      Filter.vertex_type([Module]),
      Filter.vertex_type([Application])
    ])

# `negate`

```elixir
@spec negate(filter()) :: filter()
```

Negates a filter using NOT logic.

A vertex must NOT pass the filter to be included in the result.

## Examples

    # Everything except modules
    Filter.negate(Filter.vertex_type([Module]))

# `reachable_from`

```elixir
@spec reachable_from([Clarity.Vertex.t()]) :: filter()
```

Creates a filter that includes vertices reachable from any of the specified vertices.

# `vertex_type`

```elixir
@spec vertex_type([module()]) :: filter()
```

Creates a filter that includes only vertices of the specified types.

Takes a list of modules (struct types) and includes only vertices whose
`__struct__` field matches one of the specified types.

## Examples

    # Only application vertices
    Filter.vertex_type([Clarity.Vertex.Application])

    # Only modules and applications
    Filter.vertex_type([Clarity.Vertex.Module, Clarity.Vertex.Application])

# `within_steps`

```elixir
@spec within_steps(Clarity.Vertex.t(), non_neg_integer(), non_neg_integer()) ::
  filter()
```

Creates a filter that includes vertices within the specified number of steps
from a center vertex.

This filter includes vertices reachable within `max_outgoing_steps` forward hops
OR `max_incoming_steps` backward hops from the center vertex.

---

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