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

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]

Type of a node.

Type of an edge.

Type of an iterator over all nodes.

Type of an iterator over all edges.

Type of an iterator over incident edges.

Return the number of nodes.

Return the number of edges.

Return the nodes connected by an edge. Read more

Return an iterator over all nodes.

Return an iterator over all edges. Read more

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]

Type of an iterator over the forward edges leaving a node.

Type of an iterator over the backward edges entering a node.

Return the source node of an edge.

Return the sink node of an edge.

Return an iterator over the outgoing edges of a node. Read more

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]

Return true if e is the reverse edge of f.

Return the reverse edge of e.

Return true if e is a forward edge.

Return the forward edge of e. Read more

Return true if e is a backward edge.

Return the backward edge of e. Read more

Return the source of the directed edge e. Read more

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]

Return a unique id associated with a node.

Return the node associated with the given id. Read more

Return a unique id associated with an edge. Read more

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]

Return a unique id associated with a directed edge. Read more

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]

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

Return the graph attributes.

Return the graph attributes.

Return the attributes of a node.

Return the attributes of a node.

Return the attributes of an edge.

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]

Return the attributes of a biedge.

Return the attributes of a biedge.

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
[src]

Auto Trait Implementations

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