Skip to main content

DirectlyFollowsGraph

Struct DirectlyFollowsGraph 

Source
pub struct DirectlyFollowsGraph {
    pub activities: HashMap<String, u64>,
    pub arcs: HashMap<(String, String), u64>,
    pub start_activities: HashMap<String, u64>,
    pub end_activities: HashMap<String, u64>,
    pub trace_count: u64,
}
Expand description

A mined directly-follows graph as defined by van der Aalst (2016 §7.2).

Formally: (Σ, →_L, #_Σ(L), start_L, end_L) where

  • Σ = set of activities
  • →_L = directly-follows relation (present as a key in arcs)
  • #_Σ(L) = activity frequency function
  • start_L = start-activity frequency function
  • end_L = end-activity frequency function

This is the discovery result — the value that DFG mining algorithms produce. It is distinct from Dfg, which is the structural type used for conformance checking (shape only, no frequencies).

§Construction

Build via DfgMiner:

use wasm4pm_compat::dfg::{DfgMiner, DirectlyFollowsGraph};

let mut miner = DfgMiner::new();
miner.record_trace(&["register", "check", "approve"]);
miner.record_trace(&["register", "reject"]);
let dfg = miner.build();

assert_eq!(dfg.activity_count("register"), 2);
assert_eq!(dfg.arc_count("register", "check"), 1);
assert_eq!(dfg.start_count("register"), 2);
assert_eq!(dfg.end_count("approve"), 1);
assert_eq!(dfg.end_count("reject"), 1);

Fields§

§activities: HashMap<String, u64>

Activity occurrence frequencies: #_Σ(L) — how often each activity appeared across all traces.

§arcs: HashMap<(String, String), u64>

Directly-follows arc frequencies: for each (a, b) ∈ →_L, how often b directly followed a in a trace.

§start_activities: HashMap<String, u64>

Start activity frequencies: start_L(a) — how often activity a was the first activity in a trace.

§end_activities: HashMap<String, u64>

End activity frequencies: end_L(a) — how often activity a was the last activity in a trace.

§trace_count: u64

Number of traces processed.

Implementations§

Source§

impl DirectlyFollowsGraph

Source

pub fn empty() -> Self

Construct an empty DFG (zero traces, no activities or arcs).

Prefer DfgMiner for incremental construction from traces.

Source

pub fn activity_count(&self, activity: &str) -> u64

Activity occurrence count (0 if not present).

use wasm4pm_compat::dfg::DfgMiner;
let dfg = DfgMiner::from_traces([&["A", "B"][..]]);
assert_eq!(dfg.activity_count("A"), 1);
assert_eq!(dfg.activity_count("X"), 0);
Source

pub fn arc_count(&self, from: &str, to: &str) -> u64

Directly-follows arc frequency (a → b). 0 if the arc does not exist.

use wasm4pm_compat::dfg::DfgMiner;
let dfg = DfgMiner::from_traces([&["A", "B", "B"][..]]);
assert_eq!(dfg.arc_count("A", "B"), 1);
assert_eq!(dfg.arc_count("B", "B"), 1);
assert_eq!(dfg.arc_count("B", "A"), 0);
Source

pub fn start_count(&self, activity: &str) -> u64

How often activity started a trace.

use wasm4pm_compat::dfg::DfgMiner;
let dfg = DfgMiner::from_traces([&["A", "B"][..], &["A", "C"][..]]);
assert_eq!(dfg.start_count("A"), 2);
assert_eq!(dfg.start_count("B"), 0);
Source

pub fn end_count(&self, activity: &str) -> u64

How often activity ended a trace.

use wasm4pm_compat::dfg::DfgMiner;
let dfg = DfgMiner::from_traces([&["A", "B"][..], &["A", "C"][..]]);
assert_eq!(dfg.end_count("B"), 1);
assert_eq!(dfg.end_count("C"), 1);
assert_eq!(dfg.end_count("A"), 0);
Source

pub fn follows(&self, from: &str, to: &str) -> bool

Whether arc a → b exists in the directly-follows relation.

Van der Aalst (2016): a >_L b iff arc_count(a, b) > 0.

Source

pub fn causes(&self, a: &str, b: &str) -> bool

Causality: a → b if a >_L b and NOT b >_L a.

Van der Aalst’s α-algorithm (2004): the causal relation used to identify sequential pairs in the Alpha algorithm.

Source

pub fn parallel(&self, a: &str, b: &str) -> bool

Parallel: a || b if a >_L b AND b >_L a.

Van der Aalst’s α-algorithm (2004): parallel activities that can co-occur and thus appear in both orders.

Source

pub fn exclusive(&self, a: &str, b: &str) -> bool

Choice: a # b (exclusive) if NOT a >_L b AND NOT b >_L a.

Van der Aalst’s α-algorithm (2004): activities that never directly follow each other are in exclusive choice.

Source

pub fn activities_sorted(&self) -> Vec<&str>

Sorted activity names for deterministic iteration.

Source

pub fn to_structural_dfg(&self) -> Option<Dfg>

Convert to the structural Dfg shape (for conformance checking).

Frequency information is preserved in arc weights; start/end activities and per-node frequencies are dropped (structural shape only). Returns None if the DFG is empty (no activities).

Trait Implementations§

Source§

impl Clone for DirectlyFollowsGraph

Source§

fn clone(&self) -> DirectlyFollowsGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DirectlyFollowsGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for DirectlyFollowsGraph

Source§

fn default() -> DirectlyFollowsGraph

Returns the “default value” for a type. Read more
Source§

impl Eq for DirectlyFollowsGraph

Source§

impl PartialEq for DirectlyFollowsGraph

Source§

fn eq(&self, other: &DirectlyFollowsGraph) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for DirectlyFollowsGraph

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.