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 inarcs)#_Σ(L)= activity frequency functionstart_L= start-activity frequency functionend_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: u64Number of traces processed.
Implementations§
Source§impl DirectlyFollowsGraph
impl DirectlyFollowsGraph
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct an empty DFG (zero traces, no activities or arcs).
Prefer DfgMiner for incremental construction from traces.
Sourcepub fn activity_count(&self, activity: &str) -> u64
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);Sourcepub fn arc_count(&self, from: &str, to: &str) -> u64
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);Sourcepub fn start_count(&self, activity: &str) -> u64
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);Sourcepub fn end_count(&self, activity: &str) -> u64
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);Sourcepub fn follows(&self, from: &str, to: &str) -> bool
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.
Sourcepub fn causes(&self, a: &str, b: &str) -> bool
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.
Sourcepub fn parallel(&self, a: &str, b: &str) -> bool
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.
Sourcepub fn exclusive(&self, a: &str, b: &str) -> bool
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.
Sourcepub fn activities_sorted(&self) -> Vec<&str>
pub fn activities_sorted(&self) -> Vec<&str>
Sorted activity names for deterministic iteration.
Sourcepub fn to_structural_dfg(&self) -> Option<Dfg>
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
impl Clone for DirectlyFollowsGraph
Source§fn clone(&self) -> DirectlyFollowsGraph
fn clone(&self) -> DirectlyFollowsGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DirectlyFollowsGraph
impl Debug for DirectlyFollowsGraph
Source§impl Default for DirectlyFollowsGraph
impl Default for DirectlyFollowsGraph
Source§fn default() -> DirectlyFollowsGraph
fn default() -> DirectlyFollowsGraph
impl Eq for DirectlyFollowsGraph
Source§impl PartialEq for DirectlyFollowsGraph
impl PartialEq for DirectlyFollowsGraph
Source§fn eq(&self, other: &DirectlyFollowsGraph) -> bool
fn eq(&self, other: &DirectlyFollowsGraph) -> bool
self and other values to be equal, and is used by ==.