> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/getzep/graphiti/llms.txt
> Use this file to discover all available pages before exploring further.

# Edge Types

> Edge types for representing relationships between nodes in Graphiti knowledge graphs

# Edge Types

Graphiti uses five edge types to represent different kinds of relationships in the knowledge graph. All edges inherit from the base `Edge` class and share common fields for identification, grouping, and timestamps.

## Base Edge

The abstract base class that all edge types inherit from.

<ParamField path="uuid" type="str" required>
  Unique identifier for the edge. Automatically generated using UUID4 if not provided.
</ParamField>

<ParamField path="group_id" type="str" required>
  Partition identifier for the graph. Used to organize edges into logical groups or namespaces.
</ParamField>

<ParamField path="source_node_uuid" type="str" required>
  UUID of the source node in this relationship.
</ParamField>

<ParamField path="target_node_uuid" type="str" required>
  UUID of the target node in this relationship.
</ParamField>

<ParamField path="created_at" type="datetime" required>
  Timestamp of when the edge was created.
</ParamField>

## EntityEdge

Represents a `RELATES_TO` relationship between two entity nodes, containing a fact about their relationship.

### Fields

Inherits all fields from `Edge`, plus:

<ParamField path="name" type="str" required>
  Name of the edge, describing the relation type (e.g., "works\_at", "located\_in", "friend\_of").
</ParamField>

<ParamField path="fact" type="str" required>
  A factual statement representing the edge and the nodes it connects. This is the semantic content of the relationship.
</ParamField>

<ParamField path="fact_embedding" type="list[float] | None">
  Vector embedding of the fact, used for semantic similarity searches. Generated using the configured embedder client.
</ParamField>

<ParamField path="episodes" type="list[str]">
  List of episode UUIDs that reference or mention this entity edge. Default: empty list.
</ParamField>

<ParamField path="expired_at" type="datetime | None">
  Timestamp of when the edge was invalidated or marked as expired.
</ParamField>

<ParamField path="valid_at" type="datetime | None">
  Timestamp of when the fact became true or valid.
</ParamField>

<ParamField path="invalid_at" type="datetime | None">
  Timestamp of when the fact stopped being true.
</ParamField>

<ParamField path="attributes" type="dict[str, Any]">
  Additional attributes of the edge. Content depends on the edge name and can store custom properties. Default: empty dict.
</ParamField>

### Methods

<ResponseField name="generate_embedding" type="async method">
  Generates and stores the fact embedding for this edge.

  **Parameters:**

  * `embedder: EmbedderClient` - The embedder client to use for generating embeddings

  **Returns:** `list[float]` - The generated embedding vector
</ResponseField>

<ResponseField name="load_fact_embedding" type="async method">
  Loads the fact embedding from the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance

  **Raises:** `EdgeNotFoundError` if the edge doesn't exist
</ResponseField>

<ResponseField name="save" type="async method">
  Persists the entity edge to the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

### Class Methods

<ResponseField name="get_by_uuid" type="async classmethod">
  Retrieves a single entity edge by UUID.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuid: str`

  **Returns:** `EntityEdge`

  **Raises:** `EdgeNotFoundError` if not found
</ResponseField>

<ResponseField name="get_by_uuids" type="async classmethod">
  Retrieves multiple entity edges by UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`

  **Returns:** `list[EntityEdge]`
</ResponseField>

<ResponseField name="get_between_nodes" type="async classmethod">
  Retrieves all entity edges between two specific nodes.

  **Parameters:**

  * `driver: GraphDriver`
  * `source_node_uuid: str` - UUID of the source entity node
  * `target_node_uuid: str` - UUID of the target entity node

  **Returns:** `list[EntityEdge]`
</ResponseField>

<ResponseField name="get_by_node_uuid" type="async classmethod">
  Retrieves all entity edges connected to a specific node.

  **Parameters:**

  * `driver: GraphDriver`
  * `node_uuid: str` - UUID of the entity node

  **Returns:** `list[EntityEdge]`
</ResponseField>

<ResponseField name="get_by_group_ids" type="async classmethod">
  Retrieves entity edges by group IDs with optional pagination.

  **Parameters:**

  * `driver: GraphDriver`
  * `group_ids: list[str]`
  * `limit: int | None` - Maximum number of results (optional)
  * `uuid_cursor: str | None` - UUID cursor for pagination (optional)
  * `with_embeddings: bool` - Whether to include embeddings (default: False)

  **Returns:** `list[EntityEdge]`

  **Raises:** `GroupsEdgesNotFoundError` if no edges found
</ResponseField>

## EpisodicEdge

Represents a `MENTIONS` relationship from an episodic node to an entity node, indicating that the episode mentions the entity.

### Fields

Inherits all fields from `Edge` with no additional fields.

### Methods

<ResponseField name="save" type="async method">
  Persists the episodic edge to the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

### Class Methods

<ResponseField name="get_by_uuid" type="async classmethod">
  Retrieves a single episodic edge by UUID.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuid: str`

  **Returns:** `EpisodicEdge`

  **Raises:** `EdgeNotFoundError` if not found
</ResponseField>

<ResponseField name="get_by_uuids" type="async classmethod">
  Retrieves multiple episodic edges by UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`

  **Returns:** `list[EpisodicEdge]`

  **Raises:** `EdgeNotFoundError` if not found
</ResponseField>

<ResponseField name="get_by_group_ids" type="async classmethod">
  Retrieves episodic edges by group IDs with optional pagination.

  **Parameters:**

  * `driver: GraphDriver`
  * `group_ids: list[str]`
  * `limit: int | None` - Maximum number of results (optional)
  * `uuid_cursor: str | None` - UUID cursor for pagination (optional)

  **Returns:** `list[EpisodicEdge]`

  **Raises:** `GroupsEdgesNotFoundError` if no edges found
</ResponseField>

## CommunityEdge

Represents a `HAS_MEMBER` relationship from a community node to an entity node, indicating that the entity is a member of the community.

### Fields

Inherits all fields from `Edge` with no additional fields.

### Methods

<ResponseField name="save" type="async method">
  Persists the community edge to the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

### Class Methods

<ResponseField name="get_by_uuid" type="async classmethod">
  Retrieves a single community edge by UUID.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuid: str`

  **Returns:** `CommunityEdge`
</ResponseField>

<ResponseField name="get_by_uuids" type="async classmethod">
  Retrieves multiple community edges by UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`

  **Returns:** `list[CommunityEdge]`
</ResponseField>

<ResponseField name="get_by_group_ids" type="async classmethod">
  Retrieves community edges by group IDs with optional pagination.

  **Parameters:**

  * `driver: GraphDriver`
  * `group_ids: list[str]`
  * `limit: int | None` - Maximum number of results (optional)
  * `uuid_cursor: str | None` - UUID cursor for pagination (optional)

  **Returns:** `list[CommunityEdge]`
</ResponseField>

## HasEpisodeEdge

Represents a `HAS_EPISODE` relationship from a saga node to an episodic node, indicating that the episode is part of the saga.

### Fields

Inherits all fields from `Edge` with no additional fields.

### Methods

<ResponseField name="save" type="async method">
  Persists the has-episode edge to the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

<ResponseField name="delete" type="async method">
  Deletes the has-episode edge from the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

### Class Methods

<ResponseField name="get_by_uuid" type="async classmethod">
  Retrieves a single has-episode edge by UUID.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuid: str`

  **Returns:** `HasEpisodeEdge`

  **Raises:** `EdgeNotFoundError` if not found
</ResponseField>

<ResponseField name="get_by_uuids" type="async classmethod">
  Retrieves multiple has-episode edges by UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`

  **Returns:** `list[HasEpisodeEdge]`
</ResponseField>

<ResponseField name="get_by_group_ids" type="async classmethod">
  Retrieves has-episode edges by group IDs with optional pagination.

  **Parameters:**

  * `driver: GraphDriver`
  * `group_ids: list[str]`
  * `limit: int | None` - Maximum number of results (optional)
  * `uuid_cursor: str | None` - UUID cursor for pagination (optional)

  **Returns:** `list[HasEpisodeEdge]`
</ResponseField>

## NextEpisodeEdge

Represents a `NEXT_EPISODE` relationship from one episodic node to another, forming a sequential chain of episodes.

### Fields

Inherits all fields from `Edge` with no additional fields.

### Methods

<ResponseField name="save" type="async method">
  Persists the next-episode edge to the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

<ResponseField name="delete" type="async method">
  Deletes the next-episode edge from the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

### Class Methods

<ResponseField name="get_by_uuid" type="async classmethod">
  Retrieves a single next-episode edge by UUID.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuid: str`

  **Returns:** `NextEpisodeEdge`

  **Raises:** `EdgeNotFoundError` if not found
</ResponseField>

<ResponseField name="get_by_uuids" type="async classmethod">
  Retrieves multiple next-episode edges by UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`

  **Returns:** `list[NextEpisodeEdge]`
</ResponseField>

<ResponseField name="get_by_group_ids" type="async classmethod">
  Retrieves next-episode edges by group IDs with optional pagination.

  **Parameters:**

  * `driver: GraphDriver`
  * `group_ids: list[str]`
  * `limit: int | None` - Maximum number of results (optional)
  * `uuid_cursor: str | None` - UUID cursor for pagination (optional)

  **Returns:** `list[NextEpisodeEdge]`
</ResponseField>

## Common Edge Operations

All edge types support the following operations:

### Delete Operations

<ResponseField name="delete" type="async method">
  Deletes the edge from the graph database.

  **Parameters:**

  * `driver: GraphDriver` - The graph driver instance
</ResponseField>

<ResponseField name="delete_by_uuids" type="async classmethod">
  Deletes multiple edges by their UUIDs.

  **Parameters:**

  * `driver: GraphDriver`
  * `uuids: list[str]`
</ResponseField>

## Helper Functions

<ResponseField name="create_entity_edge_embeddings" type="async function">
  Batch generates embeddings for multiple entity edges.

  **Parameters:**

  * `embedder: EmbedderClient`
  * `edges: list[EntityEdge]`

  Filters out edges with empty facts and generates embeddings for the remaining edges in batch.
</ResponseField>

## Graph Relationship Types

The following relationship types are used in the graph database:

* **RELATES\_TO** - EntityEdge connecting two entity nodes
* **MENTIONS** - EpisodicEdge from an episode to an entity it mentions
* **HAS\_MEMBER** - CommunityEdge from a community to a member entity
* **HAS\_EPISODE** - HasEpisodeEdge from a saga to an episode
* **NEXT\_EPISODE** - NextEpisodeEdge linking sequential episodes

## Related

* [Node Types](/api/nodes) - Learn about node types in the graph
* [Episodes](/api/episodes) - Learn about episode types and processing
* [Search](/api/search) - Search across edges in the knowledge graph
