Struct rs_graph::attributed::Attributed
source · Expand description
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::{Graph, LinkedListGraph, classes};
use rs_graph::{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
sourceimpl<'a, G, Gx, Nx, Ex, Ax> AttributedGraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: 'a + IndexGraph<'a>,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
impl<'a, G, Gx, Nx, Ex, Ax> AttributedGraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: 'a + IndexGraph<'a>,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
type Graph = G
type Attributes = GraphAttrs<'a, G, Gx, Nx, Ex, Ax>
sourcefn split(&'a mut self) -> (&'_ G, Self::Attributes)
fn split(&'a mut self) -> (&'_ G, Self::Attributes)
Return a read-only graph reference and a mutable attributes reference.
sourceimpl<'a, G, Gx, Nx, Ex, Ax> AttributedNetwork<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: 'a + IndexNetwork<'a>,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
impl<'a, G, Gx, Nx, Ex, Ax> AttributedNetwork<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: 'a + IndexNetwork<'a>,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
sourceimpl<'a, G, Gx, Nx, Ex, Ax> Buildable for Attributed<G, Gx, Nx, Ex, Ax>where
G: Graph<'a> + Buildable,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
impl<'a, G, Gx, Nx, Ex, Ax> Buildable for Attributed<G, Gx, Nx, Ex, Ax>where
G: Graph<'a> + Buildable,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
type Builder = AttributedBuilder<<G as Buildable>::Builder, Gx, Nx, Ex, Ax>
sourceimpl<'a, G, Gx, Nx, Ex, Ax> Digraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Digraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
impl<'a, G, Gx, Nx, Ex, Ax> Digraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Digraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
type OutEdgeIter = <G as Digraph<'a>>::OutEdgeIter
type OutEdgeIter = <G as Digraph<'a>>::OutEdgeIter
Type of an iterator over the forward edges leaving a node.
type InEdgeIter = <G as Digraph<'a>>::InEdgeIter
type InEdgeIter = <G as Digraph<'a>>::InEdgeIter
Type of an iterator over the backward edges entering a node.
sourcefn outedges(&'a self, u: Self::Node) -> Self::OutEdgeIter
fn outedges(&'a self, u: Self::Node) -> Self::OutEdgeIter
Return an iterator over the outgoing edges of a node. Read more
sourcefn inedges(&'a self, u: Self::Node) -> Self::InEdgeIter
fn inedges(&'a self, u: Self::Node) -> Self::InEdgeIter
Return an iterator over the incoming edges of a node. Read more
sourceimpl<'a, G, Gx, Nx, Ex, Ax> Graph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Graph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
impl<'a, G, Gx, Nx, Ex, Ax> Graph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Graph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
sourceimpl<'a, G, Gx, Nx, Ex, Ax> IndexGraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: IndexGraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
impl<'a, G, Gx, Nx, Ex, Ax> IndexGraph<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: IndexGraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
sourceimpl<'a, G, Gx, Nx, Ex, Ax> IndexNetwork<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: IndexNetwork<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
impl<'a, G, Gx, Nx, Ex, Ax> IndexNetwork<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: IndexNetwork<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
sourceimpl<'a, G, Gx, Nx, Ex, Ax> Network<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Network<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
impl<'a, G, Gx, Nx, Ex, Ax> Network<'a> for Attributed<G, Gx, Nx, Ex, Ax>where
G: Network<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
sourcefn is_reverse(&self, e: Self::Edge, f: Self::Edge) -> bool
fn is_reverse(&self, e: Self::Edge, f: Self::Edge) -> bool
Return true if e is the reverse edge of f.
sourcefn is_forward(&self, e: Self::Edge) -> bool
fn is_forward(&self, e: Self::Edge) -> bool
Return true if e is a forward edge.
sourcefn is_backward(&self, e: Self::Edge) -> bool
fn is_backward(&self, e: Self::Edge) -> bool
Return true if e is a backward edge.
Auto Trait Implementations
impl<G, Gx, Nx, Ex, Ax> RefUnwindSafe for Attributed<G, Gx, Nx, Ex, Ax>where
Ax: RefUnwindSafe,
Ex: RefUnwindSafe,
G: RefUnwindSafe,
Gx: RefUnwindSafe,
Nx: RefUnwindSafe,
impl<G, Gx, Nx, Ex, Ax> Send for Attributed<G, Gx, Nx, Ex, Ax>where
Ax: Send,
Ex: Send,
G: Send,
Gx: Send,
Nx: Send,
impl<G, Gx, Nx, Ex, Ax> Sync for Attributed<G, Gx, Nx, Ex, Ax>where
Ax: Sync,
Ex: Sync,
G: Sync,
Gx: Sync,
Nx: Sync,
impl<G, Gx, Nx, Ex, Ax> Unpin for Attributed<G, Gx, Nx, Ex, Ax>where
Ax: Unpin,
Ex: Unpin,
G: Unpin,
Gx: Unpin,
Nx: Unpin,
impl<G, Gx, Nx, Ex, Ax> UnwindSafe for Attributed<G, Gx, Nx, Ex, Ax>where
Ax: UnwindSafe,
Ex: UnwindSafe,
G: UnwindSafe,
Gx: UnwindSafe,
Nx: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more