[][src]Struct product_graph_rs::product_graph_rayon::ProductGraph

pub struct ProductGraph {
    pub graph: Vec<Product>,
}

The ProductGraph is a Vector-backed graph of Products. The Products are the graph nodes, and the dependencies are weighted, directed edges. The "key" or "id" of each Product is its index in the Vector. This graph is specialized for the purpose of rapidly estimating indirect costs.

Fields

graph: Vec<Product>

Implementations

impl ProductGraph[src]

pub fn calc_for_n_iterations(&self, n: u16) -> Vec<f32>[src]

Multiple iterations of the iterative estimation for indirect costs. Performs count number of iterations and then returns the final estimates. With each iteration, the estimates become more precise. ~15 iterations gives a good estimate, ~25 is better, and ~50 is extremely precise. More iterations are needed to get accurate results if any Product depends directly or indirectly on quantities of itself that approach 1.0. For instance, if corn depends on 0.01 of itself, 15 iterations should give a good result. However, if it depends on 0.9 of itself, it could take 50 iterations to be sure.

pub fn check_graph(&self) -> Result<(), GraphError>[src]

Check the graph for errors in the dataset. If a Product depends directly or indirectly on 1.0 or more of itself, this represents either bad data or a broken economy, as it will cause the price of that Product and those that depend on it to go to infinity. Also checks for dependencies that reference vector elements out of bounds, and for values that are infinity or negative.

pub fn with_capacity(size: usize) -> ProductGraph[src]

Create a graph with a specified initial capacity. The capacity is not the size of the graph, but the amount of memory that is pre-allocated.

pub fn from_raw_graph(graph: Vec<Product>) -> ProductGraph[src]

Create a ProductGraph from a plain Vec of Products.

pub fn push(&mut self, prod: Product)[src]

Add a Product to the ProductGraph. Because Products are IDed by Vector index, be careful to insert them in the correct order.

pub fn set_dependency(
    &mut self,
    dependant: usize,
    dependency: usize,
    quantity: f32
)
[src]

Create a dependency for a Product in the graph.

pub fn generate_product_graph(count: usize) -> ProductGraph[src]

Generate a random product graph for testing and benchmarking purposes.

Trait Implementations

impl Debug for ProductGraph[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,