Skip to main content

topology_hash

Function topology_hash 

Source
pub fn topology_hash(graph: &Graph) -> i64
Expand description

Returns a 64-bit hash of the nodes and edges of graph, consistent with ==.

Equal graphs have equal hashes, and different graphs rarely do. The graph of a BiAdjacentGraph and a Graph with the same nodes and edges count as equal. Like the Hash of a graph, the hash is computed on every call: compute it once and keep it, for instance as the key of a cache of results per graph, or to see when a transformation stops changing a graph. It depends on nothing but the nodes and edges, so it is the same in every run and on every platform; a release of Graphity that changes it says so in its changelog. Every implementation of Graphity computes the same hash. It is an i64 like Java’s long, so that the numbers agree too. Equal hashes do not prove equal graphs, and graphs can be made to collide on purpose: compare with == where it matters.

Time: O(node_count + edge_count).