Struct rs_graph::attributed::Attributed
[−]
[src]
pub struct Attributed<G, Gx = (), Nx = (), Ex = (), Ax = ()> { /* fields omitted */ }
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 graph::{Graph, LinkedListGraph, classes}; use 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
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,
[src]
G: Graph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
type Node = <G as Graph<'a>>::Node
Type of a node.
type Edge = <G as Graph<'a>>::Edge
Type of an edge.
type NodeIter = <G as Graph<'a>>::NodeIter
Type of an iterator over all nodes.
type EdgeIter = <G as Graph<'a>>::EdgeIter
Type of an iterator over all edges.
type NeighIter = <G as Graph<'a>>::NeighIter
Type of an iterator over incident edges.
type Builder = AttributedBuilder<G::Builder, Gx, Nx, Ex, Ax>
The default builder to construct this graph.
fn num_nodes(&self) -> usize
Return the number of nodes.
fn num_edges(&self) -> usize
Return the number of edges.
fn enodes(&'a self, e: Self::Edge) -> (Self::Node, Self::Node)
Return the nodes connected by an edge. Read more
fn nodes(&'a self) -> Self::NodeIter
Return an iterator over all nodes.
fn edges(&'a self) -> Self::EdgeIter
Return an iterator over all edges. Read more
fn neighs(&'a self, u: Self::Node) -> Self::NeighIter
Return an iterator over the edges adjacent to some node. Read more
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,
[src]
G: Digraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
type OutEdgeIter = G::OutEdgeIter
Type of an iterator over the forward edges leaving a node.
type InEdgeIter = G::InEdgeIter
Type of an iterator over the backward edges entering a node.
fn src(&'a self, e: Self::Edge) -> Self::Node
Return the source node of an edge.
fn snk(&'a self, e: Self::Edge) -> Self::Node
Return the sink node of an edge.
fn outedges(&'a self, u: Self::Node) -> Self::OutEdgeIter
Return an iterator over the outgoing edges of a node. Read more
fn inedges(&'a self, u: Self::Node) -> Self::InEdgeIter
Return an iterator over the incoming edges of a node. Read more
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,
[src]
G: Network<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
fn is_reverse(&self, e: Self::Edge, f: Self::Edge) -> bool
Return true if e is the reverse edge of f.
fn reverse(&'a self, e: Self::Edge) -> Self::Edge
Return the reverse edge of e.
fn is_forward(&self, e: Self::Edge) -> bool
Return true if e is a forward edge.
fn forward(&'a self, e: Self::Edge) -> Self::Edge
Return the forward edge of e. Read more
fn is_backward(&self, e: Self::Edge) -> bool
Return true if e is a backward edge.
fn backward(&'a self, e: Self::Edge) -> Self::Edge
Return the backward edge of e. Read more
fn bisrc(&'a self, e: Self::Edge) -> Self::Node
Return the source of the directed edge e. Read more
fn bisnk(&'a self, e: Self::Edge) -> Self::Node
Return the sink of the directed edge e. Read more
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,
[src]
G: IndexGraph<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
fn node_id(&self, u: Self::Node) -> usize
Return a unique id associated with a node.
fn id2node(&'a self, id: usize) -> Self::Node
Return the node associated with the given id. Read more
fn edge_id(&self, e: Self::Edge) -> usize
Return a unique id associated with an edge. Read more
fn id2edge(&'a self, id: usize) -> Self::Edge
Return the edge associated with the given id. Read more
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,
[src]
G: IndexNetwork<'a>,
Gx: Default,
Nx: Default,
Ex: Default,
Ax: Default,
fn biedge_id(&self, e: Self::Edge) -> usize
Return a unique id associated with a directed edge. Read more
fn id2biedge(&'a self, id: usize) -> Self::Edge
Return the edge associated with the given id. Read more
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,
[src]
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>
fn split(&'a mut self) -> (&G, Self::Attributes)
Return a read-only graph reference and a mutable attributes reference.
fn attr(&self) -> &Gx
Return the graph attributes.
fn attr_mut(&mut self) -> &mut Gx
Return the graph attributes.
fn node(&self, u: G::Node) -> &Nx
Return the attributes of a node.
fn node_mut(&mut self, u: G::Node) -> &mut Nx
Return the attributes of a node.
fn edge(&self, e: G::Edge) -> &Ex
Return the attributes of an edge.
fn edge_mut(&mut self, e: G::Edge) -> &mut Ex
Return the attributes of an edge.
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,
[src]
G: 'a + IndexNetwork<'a>,
Gx: 'a + Default,
Nx: 'a + Default,
Ex: 'a + Default,
Ax: 'a + Default,
fn biedge(&self, e: G::Edge) -> &Ax
Return the attributes of a biedge.
fn biedge_mut(&mut self, e: G::Edge) -> &mut Ax
Return the attributes of a biedge.