Skip to main content

WeightedFramework

Struct WeightedFramework 

Source
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>

Source

pub fn new() -> Self

Create an empty framework.

Source

pub fn add_argument(&mut self, a: A)

Add an argument. Adding an argument that already exists is a no-op.

Source

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.

Source

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).

Source

pub fn arguments(&self) -> impl Iterator<Item = &A>

Iterate over all arguments.

Source

pub fn attacks(&self) -> impl Iterator<Item = &WeightedAttack<A>>

Iterate over all weighted attacks.

Source

pub fn len(&self) -> usize

Number of arguments.

Source

pub fn is_empty(&self) -> bool

Whether the framework has zero arguments.

Source

pub fn attack_count(&self) -> usize

Number of attack edges (counting parallel edges separately).

Source

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>

Source§

fn clone(&self) -> WeightedFramework<A>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<A: Debug + Clone + Eq + Hash> Debug for WeightedFramework<A>

Source§

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

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

impl<A: Clone + Eq + Hash> Default for WeightedFramework<A>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<A> Freeze for WeightedFramework<A>

§

impl<A> RefUnwindSafe for WeightedFramework<A>
where A: RefUnwindSafe,

§

impl<A> Send for WeightedFramework<A>
where A: Send,

§

impl<A> Sync for WeightedFramework<A>
where A: Sync,

§

impl<A> Unpin for WeightedFramework<A>
where A: Unpin,

§

impl<A> UnsafeUnpin for WeightedFramework<A>

§

impl<A> UnwindSafe for WeightedFramework<A>
where A: UnwindSafe,

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> 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.