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.

[src]

Return the number of nodes.

[src]

Return the number of edges.

[src]

Return the nodes connected by an edge. Read more

[src]

Return an iterator over all nodes.

[src]

Return an iterator over all edges. Read more

[src]

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.

[src]

Return the source node of an edge.

[src]

Return the sink node of an edge.

[src]

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

[src]

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]

[src]

Return true if e is the reverse edge of f.

[src]

Return the reverse edge of e.

[src]

Return true if e is a forward edge.

[src]

Return the forward edge of e. Read more

[src]

Return true if e is a backward edge.

[src]

Return the backward edge of e. Read more

[src]

Return the source of the directed edge e. Read more

[src]

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]

[src]

Return a unique id associated with a node.

[src]

Return the node associated with the given id. Read more

[src]

Return a unique id associated with an edge. Read more

[src]

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]

[src]

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

[src]

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]

[src]

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

[src]

Return the graph attributes.

[src]

Return the graph attributes.

[src]

Return the attributes of a node.

[src]

Return the attributes of a node.

[src]

Return the attributes of an edge.

[src]

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]

[src]

Return the attributes of a biedge.

[src]

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]