Skip to content

Models

Core data structures used throughout synamine.

Event Log

EventLogSchema dataclass

EventLogSchema(
    case_id: str = DEFAULT_CASE_ID,
    activity: str = DEFAULT_ACTIVITY,
    timestamp: str = DEFAULT_TIMESTAMP,
    resource: str | None = None,
    cost: str | None = None,
    lifecycle: str | None = None,
    extra_attributes: dict[str, str] = dict(),
)

Defines the column mapping for an event log DataFrame.

Event dataclass

Event(
    activity: str,
    timestamp: datetime,
    resource: str | None = None,
    attributes: dict[str, Any] = dict(),
)

A single event within a trace.

Trace dataclass

Trace(
    case_id: str,
    events: tuple[Event, ...],
    attributes: dict[str, Any] = dict(),
)

An ordered sequence of events belonging to a single case.

EventLog

EventLog(
    data: DataFrame, schema: EventLogSchema | None = None
)

Primary event log representation, backed by a pandas DataFrame.

All algorithms accept EventLog. Internally wraps a DataFrame for performance; exposes trace-level iteration for convenience.

Directly-Follows Graph

DirectlyFollowsGraph dataclass

DirectlyFollowsGraph(
    edges: dict[tuple[str, str], int] = dict(),
    start_activities: dict[str, int] = dict(),
    end_activities: dict[str, int] = dict(),
)

A graph of directly-follows relations between activities.

Each edge (A, B) with count N means activity B directly followed activity A in N traces.

Petri Net

Place dataclass

Place(name: str, properties: dict[str, Any] = dict())

Transition dataclass

Transition(
    name: str,
    label: str | None = None,
    properties: dict[str, Any] = dict(),
)

PetriNet dataclass

PetriNet(
    name: str = "",
    places: set[Place] = set(),
    transitions: set[Transition] = set(),
    arcs: set[Arc] = set(),
    initial_marking: Marking = Marking(),
    final_marking: Marking = Marking(),
)

Marking dataclass

Marking(tokens: dict[Place, int] = dict())

Process Tree

Operator

Bases: Enum

ProcessTree dataclass

ProcessTree(
    operator: Operator | None = None,
    label: str | None = None,
    parent: ProcessTree | None = None,
    children: list[ProcessTree] = list(),
)

Variant Trie

VariantTrieNode dataclass

VariantTrieNode(
    activity: str | None = None,
    count: int = 0,
    end_count: int = 0,
    depth: int = 0,
    children: dict[str, VariantTrieNode] = dict(),
    parent: VariantTrieNode | None = None,
)

A node in the variant trie.

is_branching property

is_branching: bool

True if this node has more than one child (a divergence point).

frequency property

frequency: float

Proportion of total traces passing through this node.

VariantTrie dataclass

VariantTrie(root: VariantTrieNode = VariantTrieNode())

A prefix tree of trace variants.

Built from an EventLog, each path root->leaf represents a unique process variant. Branch points reveal where executions diverge. Designed for dendrogram visualization.

Example

import synamine log = synamine.read_csv("orders.csv") trie = synamine.discover_variant_trie(log) print(trie) VariantTrie(variants=5, traces=1000, max_depth=8) synamine.view_variant_trie(trie) # Opens dendrogram

num_variants property

num_variants: int

Count of unique variants (leaf nodes).

num_traces property

num_traces: int

Total traces represented in the trie.

max_depth property

max_depth: int

Length of the longest variant.

from_log classmethod

from_log(log: EventLog) -> VariantTrie

Build a variant trie from an event log.

PARAMETER DESCRIPTION
log

The event log to build the trie from.

TYPE: EventLog

RETURNS DESCRIPTION
VariantTrie

The constructed prefix tree.

leaves

leaves() -> Iterator[VariantTrieNode]

Yield all leaf nodes (variant endpoints).

branches

branches() -> Iterator[VariantTrieNode]

Yield all branching nodes (divergence points).

variants

variants() -> Iterator[tuple[tuple[str, ...], int]]

Yield all variants as (activity_sequence, count) tuples, sorted by count descending.

prune

prune(min_count: int) -> VariantTrie

Return a new trie with nodes below min_count removed.

Prunes at the node level: any branch where the node count drops below min_count is cut off. This preserves the full structure of high-traffic paths and keeps the root count from the original trie so that percentages remain relative to the full log.

BPMN

BpmnGraph dataclass

BpmnGraph(
    name: str = "",
    nodes: set[BpmnNode] = set(),
    edges: set[BpmnEdge] = set(),
)