# majortrack.similarities¶

group_similarity_fraction(from_group, to_group)[source]

Fraction of nodes present in one group that come from the another group.

Parameters
• from_group (set) – group from which nodes might come.

• to_group (set) – group in which the nodes are.

group_similarity_jaccard(group_1, group_2, N=None)[source]

Compute the similarity, i.e. the fraction of agreeing nodes, between two groups of different groupings.

The similarity is given by 1 - the fraction of nodes belonging to the symmetric difference (or disjunctive union) between the two groups. Or, said differently, the fraction of nodes that agree on their respective status towards both provided groups. The status of a node towards a group can either be member or non-member of that group. A node with identical status towards both groups contributes with a summand of 1/N to the similarity of those two groups.

If the total size of the networks, N, is provided, then also nodes contribute to the similarity of the groups which are non-members for both of the groups. Without the total size of the network, N=None, the groups similarity only considers nodes present in both groups as contributing to the similarity and thus is equivalent to the Jaccard index.

group_1: set

members of a group

group_2: set

members of another group

N: int (default=None)

Number of nodes in the network. If not provided, then the Jaccard index is computed.

l_index(*groupings)[source]

Todo

This is not implemented.

node_l_index(node_id, *groupings, **kwargs)[source]

Return the node L-index for a node and a set of groupings.

Todo

Add option to only consider nodes that ever were in the same group as the focal node.

Parameters
• node_id (int) – Identifier of the focal node.

• groupings (list) –

Each grouping must be a list of lists where each element is a node. So a grouping must be of the form:

[[n0, node_id, n2], [n3, n4, ...], ...]
# <    group 1  >    < group 2 > ...


Note

Each grouping must contain the same set of nodes.