AdjacencyListFlowGraph

Struct AdjacencyListFlowGraph 

Source
pub struct AdjacencyListFlowGraph<N = ()>
where N: Clone + Debug,
{ /* private fields */ }
Expand description

An adapter for petgraph::Graph to be used as a FlowGraph and OriginalGraphView.

This graph is directed. Edge weights are f64 representing capacities. Node weights are generic (N), defaulting to ().

It assumes that vertex indices used by algorithms (usize) correspond directly to petgraph::NodeIndex::index() values. This holds if nodes are added and not removed.

Implementations§

Source§

impl<N> AdjacencyListFlowGraph<N>
where N: Clone + Debug,

Source

pub fn new() -> Self

Creates a new, empty AdjacencyListFlowGraph.

Source

pub fn add_node(&mut self, weight: N) -> usize

Adds a new node with the given weight to the graph.

§Arguments
  • weight: The weight of the node (e.g., () if no specific data is needed).
§Returns

The usize index of the newly added node. This index is what should be used in add_edge calls and by flow algorithms.

Source

pub fn add_edge(&mut self, u_idx: usize, v_idx: usize, capacity: f64)

Adds a directed edge to the graph.

§Arguments
  • u_idx: The usize index of the source node (previously returned by add_node).
  • v_idx: The usize index of the target node (previously returned by add_node).
  • capacity: The capacity of the edge (must be f64).
§Panics

Panics if u_idx or v_idx do not correspond to existing nodes in the graph, or if they are out of bounds for the current node count. petgraph itself panics if NodeIndexs are invalid.

Trait Implementations§

Source§

impl<N> Clone for AdjacencyListFlowGraph<N>
where N: Clone + Debug + Clone,

Source§

fn clone(&self) -> AdjacencyListFlowGraph<N>

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<N> Debug for AdjacencyListFlowGraph<N>
where N: Clone + Debug + Debug,

Source§

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

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

impl<N> Default for AdjacencyListFlowGraph<N>
where N: Default + Clone + Debug,

Default implementation for AdjacencyListFlowGraph. Creates an empty graph. Requires N to implement Default.

Source§

fn default() -> Self

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

impl<N> FlowGraph for AdjacencyListFlowGraph<N>
where N: Clone + Debug,

Implements FlowGraph for AdjacencyListFlowGraph.

Source§

fn vertex_count(&self) -> usize

Returns the number of vertices in the graph.

Source§

impl<N> OriginalGraphView for AdjacencyListFlowGraph<N>
where N: Clone + Debug,

Implements OriginalGraphView for AdjacencyListFlowGraph.

Source§

fn all_edges(&self) -> Box<dyn Iterator<Item = (usize, usize, f64)> + '_>

Returns an iterator over all edges in the graph, yielding tuples of (source_idx, target_idx, capacity).

Vertex indices are usize.

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