Edge

A directed relationship between two nodes.

Usage

Source

Edge(
    source,
    target,
    relation,
    weight=1.0,
    metadata=dict(),
)

Parameters

source: str

ID of the source node.

target: str

ID of the target node.

relation: str

Label describing the relationship (e.g., "mentions", "belongs_to", "related_to").

weight: float = 1.0

Numeric weight/strength of the relationship (0.0–1.0).

metadata: dict[str, Any] = dict()
Arbitrary key-value metadata.

Examples

import talk_box as tb

edge = tb.Edge(
    source="doc-001",
    target="entity-python",
    relation="mentions",
    weight=0.9,
)
edge.relation  # "mentions"