shd#
- causalbase.metrics.shd(g1, g2)[source]#
Return the structural Hamming distance between two graphs.
- Parameters:
- g1DAG or PDAG
First graph.
- g2DAG or PDAG
Second graph, with the same num_nodes as g1.
- Returns:
- int
The number of node pairs that are adjacent in only one graph, or adjacent in both but marked differently (
u -> v,v -> uoru - v). Between DAGs, the additions, deletions and reversals that turn one into the other.
- Raises:
- ValueError
If g1 and g2 have a different number of nodes.