pub struct Attributed<G, Gx = (), Nx = (), Ex = (), Ax = ()> { /* private fields */ }
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

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.
Return the attributes of a biedge.
Return the attributes of a biedge.
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
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
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
Return a unique id associated with a directed edge. Read more
Return the edge associated with the given id. Read more
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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.