pub fn is_same_graph(g1: &Graph, g2: &Graph) -> boolExpand description
Returns true iff g1 and g2 are identical as labelled
graphs: same vertex count, same directedness, same edge
multiset. Edges differing only in storage order (or, for
undirected, in endpoint orientation) are treated as identical.
Time complexity: O(E log E) due to the canonical sort of the
two edge lists — slightly worse than upstream’s O(E) walk over
pre-sorted ii indices, but our Graph keeps that sort as a
private detail so we re-sort here. Edge counts up to a few
million sort in well under a second.
Note this is not isomorphism: vertex labels matter. Use a dedicated isomorphism checker (future AWU) if you need to ignore relabelling.
Counterpart of igraph_is_same_graph from
references/igraph/src/graph/type_indexededgelist.c:1947.
§Examples
use rust_igraph::{Graph, is_same_graph};
// Same edge set, different insertion order ⇒ same graph.
let mut g1 = Graph::with_vertices(3);
g1.add_edge(0, 1).unwrap();
g1.add_edge(1, 2).unwrap();
let mut g2 = Graph::with_vertices(3);
g2.add_edge(1, 2).unwrap();
g2.add_edge(0, 1).unwrap();
assert!(is_same_graph(&g1, &g2));
// Same vcount + ecount but different edge set ⇒ not the same.
let mut g3 = Graph::with_vertices(3);
g3.add_edge(0, 2).unwrap();
g3.add_edge(1, 2).unwrap();
assert!(!is_same_graph(&g1, &g3));