Trait rs_graph::attributed::AttributedGraph
source · pub trait AttributedGraph<'a> {
type Graph: Graph<'a>;
type Attributes: Attributes<Node = <Self::Graph as Graph<'a>>::Node, Edge = <Self::Graph as Graph<'a>>::Edge>;
fn split(&'a mut self) -> (&'_ Self::Graph, Self::Attributes);
fn attr(&'a self) -> &'a <Self::Attributes as Attributes>::GraphAttr;
fn attr_mut(
&'a mut self
) -> &'a mut <Self::Attributes as Attributes>::GraphAttr;
fn node(
&'a self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a <Self::Attributes as Attributes>::NodeAttr;
fn node_mut(
&'a mut self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a mut <Self::Attributes as Attributes>::NodeAttr;
fn edge(
&'a self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a <Self::Attributes as Attributes>::EdgeAttr;
fn edge_mut(
&'a mut self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a mut <Self::Attributes as Attributes>::EdgeAttr;
}
Expand description
An attributed graph.
This trait adds three attributes to a graph:
- attributes for the graph itself via
attr
andattr_mut
. - attributes for the nodes via
node
andnode_mut
. - attributes for the edges via
node
andnode_mut
.
Furthermore, if you need to mutate some of the attributes, the
split
method, splits the graph into two references: one for pure
read-only graph access and one for mutable access to the
attributes. This allows to mutate the attributes while ensuring
that the graph structure remains unchanged (and thus no nodes or
edges may be added.)
Required Associated Types
type Graph: Graph<'a>
type Attributes: Attributes<Node = <Self::Graph as Graph<'a>>::Node, Edge = <Self::Graph as Graph<'a>>::Edge>
Required Methods
sourcefn split(&'a mut self) -> (&'_ Self::Graph, Self::Attributes)
fn split(&'a mut self) -> (&'_ Self::Graph, Self::Attributes)
Return a read-only graph reference and a mutable attributes reference.
sourcefn attr(&'a self) -> &'a <Self::Attributes as Attributes>::GraphAttr
fn attr(&'a self) -> &'a <Self::Attributes as Attributes>::GraphAttr
Return the graph attributes.
sourcefn attr_mut(&'a mut self) -> &'a mut <Self::Attributes as Attributes>::GraphAttr
fn attr_mut(&'a mut self) -> &'a mut <Self::Attributes as Attributes>::GraphAttr
Return the graph attributes.
sourcefn node(
&'a self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a <Self::Attributes as Attributes>::NodeAttr
fn node(
&'a self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a <Self::Attributes as Attributes>::NodeAttr
Return the attributes of a node.
sourcefn node_mut(
&'a mut self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a mut <Self::Attributes as Attributes>::NodeAttr
fn node_mut(
&'a mut self,
u: <Self::Graph as Graph<'a>>::Node
) -> &'a mut <Self::Attributes as Attributes>::NodeAttr
Return the attributes of a node.
sourcefn edge(
&'a self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a <Self::Attributes as Attributes>::EdgeAttr
fn edge(
&'a self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a <Self::Attributes as Attributes>::EdgeAttr
Return the attributes of an edge.
sourcefn edge_mut(
&'a mut self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a mut <Self::Attributes as Attributes>::EdgeAttr
fn edge_mut(
&'a mut self,
e: <Self::Graph as Graph<'a>>::Edge
) -> &'a mut <Self::Attributes as Attributes>::EdgeAttr
Return the attributes of an edge.