ash_model.multiego.jaccard_similarity

ash_model.multiego.jaccard_similarity(multiego1, multiego2)[source]

Compute the Jaccard similarity between two Multi-Ego Networks.

The Jaccard similarity is defined as the size of the intersection divided by the size of the union of the two Multi-Ego Network hyperedge sets.

Parameters:
  • multiego1 (List[Set[int]]) – first Multi-Ego Network (list of hyperedges as sets of node IDs)

  • multiego2 (List[Set[int]]) – second Multi-Ego Network (list of hyperedges as sets of node IDs)

Returns:

Jaccard similarity score in [0, 1]. Returns 0.0 if both Multi-Ego Networks are empty.

Return type:

float

Examples

>>> multiego1 = [{1, 2}, {2, 3}, {1, 3}]
>>> multiego2 = [{1, 2}, {3, 4}]
>>> sim = jaccard_similarity(multiego1, multiego2)
>>> print(f"Jaccard similarity: {sim:.3f}")