Skip to main content

reverse

Function reverse 

Source
pub fn reverse(graph: &Graph) -> IgraphResult<Graph>
Expand description

Returns a new graph with all edge directions reversed.

For directed graphs, every edge (u, v) becomes (v, u). For undirected graphs, returns a structural copy (edges unchanged).

§Examples

use rust_igraph::{Graph, reverse};

let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();

let rev = reverse(&g).unwrap();
assert!(rev.is_directed());
assert_eq!(rev.ecount(), 2);
// Edge 0→1 becomes 1→0, edge 1→2 becomes 2→1