Struct rs_graph::attributed::Attributed[][src]

pub struct Attributed<G, Gx = (), Nx = (), Ex = ()> { /* fields omitted */ }
👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Wrapper to attach attributes with a graph.

This is a wrapper struct that adds additional attributes to an arbitrary graph. The type parameters are

  • ’Gx` the type of graph attributes.
  • ’Nx` the type of node attributes.
  • ’Ex` the type of edge attributes.
  • ’Ax` the type of biedge attributes.

The attributed graph implements Graph, Digraph and Network if the the wrapped graph does.

Example

use rs_graph::{LinkedListGraph, classes, traits::*};
use rs_graph::attributed::{Attributes, Attributed, AttributedGraph};

#[derive(Default)]
struct NodeAttr {
    balance: f64,
}

#[derive(Default)]
struct EdgeAttr {
    flow: f64,
}

type MyGraph = Attributed<LinkedListGraph, (), NodeAttr, EdgeAttr>;
let mut g: MyGraph = classes::complete_bipartite(3,4);

{
    let (g, mut attr) = g.split();
    for u in g.nodes() {
        attr.node_mut(u).balance = 42.0;
    }
    for e in g.edges() {
        attr.edge_mut(e).flow = 1.5;
    }
}

assert!(g.nodes().all(|u| g.node(u).balance == 42.0));
assert!(g.edges().all(|e| g.edge(e).flow == 1.5));

Trait Implementations

impl<'a, G, Gx, Nx, Ex> AttributedGraph<'a> for Attributed<G, Gx, Nx, Ex> where
    G: 'a + IndexGraph<'a>,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

type Graph = G

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

type Attributes = GraphAttrs<'a, G, Gx, Nx, Ex>

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

fn split(&'a mut self) -> (&G, Self::Attributes)[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return a read-only graph reference and a mutable attributes reference.

fn attr(&self) -> &Gx[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the graph attributes.

fn attr_mut(&mut self) -> &mut Gx[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the graph attributes.

fn node(&self, u: G::Node) -> &Nx[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the attributes of a node.

fn node_mut(&mut self, u: G::Node) -> &mut Nx[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the attributes of a node.

fn edge(&self, e: G::Edge) -> &Ex[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the attributes of an edge.

fn edge_mut(&mut self, e: G::Edge) -> &mut Ex[src]

👎 Deprecated since 0.17.0:

use rs-graph-derive crate instead

Return the attributes of an edge.

impl<'a, G, Gx, Nx, Ex> Buildable for Attributed<G, Gx, Nx, Ex> where
    G: GraphSize<'a> + Buildable,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

type Builder = AttributedBuilder<G::Builder, Gx, Nx, Ex>

fn new_builder() -> Self::Builder[src]

Create a new builder for this graph type.

fn new_with<F>(f: F) -> Self where
    F: FnOnce(&mut Self::Builder), 
[src]

Create a new graph by passing the builder to the callback f. Read more

impl<'a, G, Gx, Nx, Ex> Directed<'a> for Attributed<G, Gx, Nx, Ex> where
    G: Directed<'a>,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

type OutIt = AttributedWrapIt<G::OutIt>

Type of a graph iterator over edges leaving a node.

type InIt = AttributedWrapIt<G::InIt>

Type of a graph iterator over edges entering a node.

type IncidentIt = AttributedWrapIt<G::IncidentIt>

Type of an iterator over all incident edges.

type DirectedEdge = G::DirectedEdge

Type of a directed edge.

fn src(&'a self, e: Self::Edge) -> Self::Node[src]

Return the source node of an edge.

fn snk(&'a self, e: Self::Edge) -> Self::Node[src]

Return the sink node of an edge.

fn out_iter(&'a self, u: Self::Node) -> Self::OutIt[src]

Return a graph iterator over the edges leaving a node.

fn in_iter(&'a self, u: Self::Node) -> Self::InIt[src]

Return a graph iterator over the edges leaving a node.

fn incident_iter(&'a self, u: Self::Node) -> Self::IncidentIt[src]

Return an iterator over all directed edges incident with a node.

fn outedges(&'a self, u: Self::Node) -> GraphIter<'a, Self, Self::OutIt>

Notable traits for GraphIter<'a, G, I>

impl<'a, G, I> Iterator for GraphIter<'a, G, I> where
    I: GraphIterator<G>, 
type Item = I::Item;
where
    Self: Sized
[src]

Return an iterator over the edges leaving a node.

fn outgoing(&'a self) -> OutEdges<'a, Self> where
    Self: Sized
[src]

Return access to the outgoing arcs via an Adjacencies trait. Read more

fn inedges(&'a self, u: Self::Node) -> GraphIter<'a, Self, Self::InIt>

Notable traits for GraphIter<'a, G, I>

impl<'a, G, I> Iterator for GraphIter<'a, G, I> where
    I: GraphIterator<G>, 
type Item = I::Item;
where
    Self: Sized
[src]

Return an iterator over the edges leaving a node.

fn incoming(&'a self) -> InEdges<'a, Self> where
    Self: Sized
[src]

Return access to the incoming arcs via an Adjacencies trait. Read more

fn incident_edges(
    &'a self,
    u: Self::Node
) -> GraphIter<'a, Self, Self::IncidentIt>

Notable traits for GraphIter<'a, G, I>

impl<'a, G, I> Iterator for GraphIter<'a, G, I> where
    I: GraphIterator<G>, 
type Item = I::Item;
where
    Self: Sized
[src]

Return an iterator over all directed edges incident with a node.

impl<G, Gx, Nx, Ex, I> GraphIterator<Attributed<G, Gx, Nx, Ex>> for AttributedWrapIt<I> where
    I: GraphIterator<G>, 
[src]

type Item = I::Item

fn next(&mut self, g: &Attributed<G, Gx, Nx, Ex>) -> Option<I::Item>[src]

fn size_hint(&self, g: &Attributed<G, Gx, Nx, Ex>) -> (usize, Option<usize>)[src]

fn count(self, g: &Attributed<G, Gx, Nx, Ex>) -> usize[src]

fn iter<'a>(self, g: &'a G) -> GraphIter<'a, G, Self>

Notable traits for GraphIter<'a, G, I>

impl<'a, G, I> Iterator for GraphIter<'a, G, I> where
    I: GraphIterator<G>, 
type Item = I::Item;
where
    G: Sized
[src]

impl<'a, G, Gx, Nx, Ex> GraphSize<'a> for Attributed<G, Gx, Nx, Ex> where
    G: GraphSize<'a>,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

type NodeIt = AttributedWrapIt<G::NodeIt>

Type of an iterator over all nodes.

type EdgeIt = AttributedWrapIt<G::EdgeIt>

Type of an iterator over all edges.

fn num_nodes(&self) -> usize[src]

Return the number of nodes in the graph.

fn num_edges(&self) -> usize[src]

Return the number of edges in the graph.

fn nodes_iter(&'a self) -> Self::NodeIt[src]

Return a graph iterator over all nodes.

fn edges_iter(&'a self) -> Self::EdgeIt[src]

Return a graph iterator over all edges. Read more

fn nodes(&'a self) -> NodeIterator<'a, Self> where
    Self: Sized
[src]

Return an iterator over all nodes.

fn edges(&'a self) -> EdgeIterator<'a, Self> where
    Self: Sized
[src]

Return an iterator over all edges. Read more

impl<'a, G, Gx, Nx, Ex> GraphType<'a> for Attributed<G, Gx, Nx, Ex> where
    G: GraphType<'a>,
    Gx: Default,
    Nx: Default,
    Ex: Default
[src]

type Node = G::Node

Type of a node.

type Edge = G::Edge

Type of an edge.

impl<'a, G, Gx, Nx, Ex> IndexGraph<'a> for Attributed<G, Gx, Nx, Ex> where
    G: IndexGraph<'a>,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

fn node_id(&self, u: Self::Node) -> usize[src]

Return a unique id associated with a node.

fn id2node(&'a self, id: usize) -> Self::Node[src]

Return the node associated with the given id. Read more

fn edge_id(&self, e: Self::Edge) -> usize[src]

Return a unique id associated with an edge. Read more

fn id2edge(&'a self, id: usize) -> Self::Edge[src]

Return the edge associated with the given id. Read more

impl<'a, G, Gx, Nx, Ex> Undirected<'a> for Attributed<G, Gx, Nx, Ex> where
    G: Undirected<'a>,
    Gx: 'a + Default,
    Nx: 'a + Default,
    Ex: 'a + Default
[src]

type NeighIt = AttributedWrapIt<G::NeighIt>

Type of a graph iterator over all incident edges.

fn enodes(&'a self, e: Self::Edge) -> (Self::Node, Self::Node)[src]

Return the nodes connected by an edge. Read more

fn neigh_iter(&'a self, u: Self::Node) -> Self::NeighIt[src]

Return a graph iterator over the edges adjacent to some node.

fn neighs(&'a self, u: Self::Node) -> GraphIter<'a, Self, Self::NeighIt>

Notable traits for GraphIter<'a, G, I>

impl<'a, G, I> Iterator for GraphIter<'a, G, I> where
    I: GraphIterator<G>, 
type Item = I::Item;
where
    Self: Sized
[src]

Return an iterator over the edges adjacent to some node.

fn neighbors(&'a self) -> Neighbors<'a, Self> where
    Self: Sized
[src]

Return access to the neighbors via an Adjacencies trait. Read more

Auto Trait Implementations

impl<G, Gx, Nx, Ex> RefUnwindSafe for Attributed<G, Gx, Nx, Ex> where
    Ex: RefUnwindSafe,
    G: RefUnwindSafe,
    Gx: RefUnwindSafe,
    Nx: RefUnwindSafe

impl<G, Gx, Nx, Ex> Send for Attributed<G, Gx, Nx, Ex> where
    Ex: Send,
    G: Send,
    Gx: Send,
    Nx: Send

impl<G, Gx, Nx, Ex> Sync for Attributed<G, Gx, Nx, Ex> where
    Ex: Sync,
    G: Sync,
    Gx: Sync,
    Nx: Sync

impl<G, Gx, Nx, Ex> Unpin for Attributed<G, Gx, Nx, Ex> where
    Ex: Unpin,
    G: Unpin,
    Gx: Unpin,
    Nx: Unpin

impl<G, Gx, Nx, Ex> UnwindSafe for Attributed<G, Gx, Nx, Ex> where
    Ex: UnwindSafe,
    G: UnwindSafe,
    Gx: UnwindSafe,
    Nx: UnwindSafe

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

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

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

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

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

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

pub fn into(self) -> U[src]

Performs the conversion.

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.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

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.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<'a, G> Digraph<'a> for G where
    G: GraphSize<'a> + Directed<'a>, 
[src]

impl<'a, G> Graph<'a> for G where
    G: GraphSize<'a> + Undirected<'a>, 
[src]

impl<'a, T> IndexDigraph<'a> for T where
    T: IndexGraph<'a> + Digraph<'a>, 
[src]