pub struct WeightedFramework<A: Clone + Eq + Hash> { /* private fields */ }Expand description
A weighted argumentation framework: a set of arguments and a list of weighted attack edges between them.
Attack weights are validated at insert time via
AttackWeight::new. Duplicate attack edges (same attacker and
target) are NOT deduplicated — each add_weighted_attack call
appends a new edge, even if one already exists. This matches Dunne
2011, which allows multigraphs with distinct-weight parallel edges.
Consumers who want deduplication should call
WeightedFramework::collapse_duplicate_attacks.
Implementations§
Source§impl<A: Clone + Eq + Hash> WeightedFramework<A>
impl<A: Clone + Eq + Hash> WeightedFramework<A>
Sourcepub fn add_argument(&mut self, a: A)
pub fn add_argument(&mut self, a: A)
Add an argument. Adding an argument that already exists is a no-op.
Sourcepub fn add_weighted_attack(
&mut self,
attacker: A,
target: A,
weight: f64,
) -> Result<(), Error>
pub fn add_weighted_attack( &mut self, attacker: A, target: A, weight: f64, ) -> Result<(), Error>
Add a weighted attack. Both endpoints are implicitly added to
the framework. Returns Error::InvalidWeight if the weight
fails validation. Parallel edges with the same endpoints but
different weights are permitted.
Sourcepub fn collapse_duplicate_attacks(&mut self) -> Result<(), Error>
pub fn collapse_duplicate_attacks(&mut self) -> Result<(), Error>
Collapse parallel edges: for each (attacker, target) pair,
keep only one edge whose weight is the sum of all parallel
edges’ weights. This is one valid aggregation strategy (sum);
Dunne 2011 does not prescribe one. Consumers who want a
different aggregation (max, min, mean) should implement it
externally.
Returns Error::InvalidWeight if the summed weight overflows
to infinity (e.g., two edges each with weight f64::MAX).
Sourcepub fn attacks(&self) -> impl Iterator<Item = &WeightedAttack<A>>
pub fn attacks(&self) -> impl Iterator<Item = &WeightedAttack<A>>
Iterate over all weighted attacks.
Sourcepub fn attack_count(&self) -> usize
pub fn attack_count(&self) -> usize
Number of attack edges (counting parallel edges separately).
Sourcepub fn sorted_weights(&self) -> Vec<f64>
pub fn sorted_weights(&self) -> Vec<f64>
Return all distinct weight values present in the framework, sorted ascending. Used by the threshold-sweep API: flip points can only occur at cumulative-sum values of these weights.
Trait Implementations§
Source§impl<A: Clone + Clone + Eq + Hash> Clone for WeightedFramework<A>
impl<A: Clone + Clone + Eq + Hash> Clone for WeightedFramework<A>
Source§fn clone(&self) -> WeightedFramework<A>
fn clone(&self) -> WeightedFramework<A>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more