Struct rs_graph::reversedigraph::ReverseDigraph[][src]

pub struct ReverseDigraph<G>(_);

A digraph wrapping an existing graph with edges in opposite directions.

The sets of outgoing and incoming edges handled by the methods of Digraph and Network are swapped, so incoming edges becoming outgoing edges and vice versa.

Example

use rs_graph::{Graph, Digraph, IndexGraph, ReverseDigraph, LinkedListGraph};
use rs_graph::reverse;
use rs_graph::classes::star;

let g = star::<LinkedListGraph>(42);
assert_eq!(g.num_nodes(), 43);
assert_eq!(g.num_edges(), 42);
assert!(g.edges().all(|e| g.node_id(g.src(e)) == 0 && g.node_id(g.snk(e)) > 0));
assert!(g.outedges(g.id2node(0)).all(|(_,v)| g.node_id(v) > 0));
assert!(g.inedges(g.id2node(0)).all(|(_,v)| g.node_id(v) == 0));
assert_eq!(g.outedges(g.id2node(0)).count(), 42);
assert_eq!(g.inedges(g.id2node(0)).count(), 0);

// Can be used by wrapping a reference.
{
    let g = reverse(&g);
    assert_eq!(g.num_nodes(), 43);
    assert_eq!(g.num_edges(), 42);
}

// Or by conversion.
let g = reverse(g);
assert_eq!(g.num_nodes(), 43);
assert_eq!(g.num_edges(), 42);
assert!(g.edges().all(|e| g.node_id(g.snk(e)) == 0 && g.node_id(g.src(e)) > 0));
assert!(g.outedges(g.id2node(0)).all(|(_,v)| g.node_id(v) == 0));
assert!(g.inedges(g.id2node(0)).all(|(_,v)| g.node_id(v) > 0));
assert_eq!(g.outedges(g.id2node(0)).count(), 0);
assert_eq!(g.inedges(g.id2node(0)).count(), 42);

Trait Implementations

impl<'a, G> Graph<'a> for ReverseDigraph<G> where
    G: Graph<'a>, 
[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> IndexGraph<'a> for ReverseDigraph<G> where
    G: IndexGraph<'a>, 
[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> Digraph<'a> for ReverseDigraph<G> where
    G: Digraph<'a>, 
[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> Network<'a> for ReverseDigraph<G> where
    G: Network<'a>, 
[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> IndexNetwork<'a> for ReverseDigraph<G> where
    G: IndexNetwork<'a>, 
[src]

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

Return the edge associated with the given id. Read more

impl<G> From<G> for ReverseDigraph<G>
[src]

Performs the conversion.

Auto Trait Implementations

impl<G> Send for ReverseDigraph<G> where
    G: Send

impl<G> Sync for ReverseDigraph<G> where
    G: Sync