[][src]Module rs_graph::adapters::network

A network graph adaptor.

A network corresponds to digraph where each of the digraph's edge is associated by a pair of edges -- the edge and its reverse edge. Hence, the network shares the node set with the underlying graph but has twice the number of edges. Each digraph can be turned into an network.

Example

use rs_graph::classes;
use rs_graph::adapters::Network;
use rs_graph::LinkedListGraph;
use rs_graph::traits::*;

let g = classes::complete_bipartite::<LinkedListGraph>(3, 4);
let n = Network::new(&g);
assert_eq!(g.num_nodes(), n.num_nodes());
assert_eq!(g.num_edges() * 2, n.num_edges());
assert!(n.nodes().take(3).all(|u| n.inedges(u).count() == 4));
assert!(n.nodes().take(3).all(|u| n.outedges(u).count() == 4));
assert!(n.nodes().take(3).all(|u| n.neighs(u).count() == 8));
assert!(n.nodes().skip(3).all(|u| n.inedges(u).count() == 3));
assert!(n.nodes().skip(3).all(|u| n.outedges(u).count() == 3));
assert!(n.nodes().skip(3).all(|u| n.neighs(u).count() == 6));

for u in n.nodes().take(3) {
    for v in n.nodes().skip(3) {
        assert_eq!(n.edges().filter(|&e| (n.src(e), n.snk(e)) == (u, v)).count(), 1);
        assert_eq!(n.edges().filter(|&e| (n.snk(e), n.src(e)) == (u, v)).count(), 1);
    }
}

Structs

Network

The network graph adaptor.

NetworkEdgeIter

Iterator over all edges of the Network.

NetworkInEdge
NetworkIncidentEdge
NetworkOutEdge

Enums

NetworkDirectedEdge

A network edge with direction information.

NetworkEdge

A network edge.