Skip to content

clustering

closed_triads

Calculates the set of edges that represent a closed triad around a given node v.

Parameters

network : Network

The network in which to calculate the list of closed triads
Source code in src/pathpyG/statistics/clustering.py
def closed_triads(g: Graph, v: str) -> Set:
    """Calculates the set of edges that represent a closed triad
    around a given node v.

    Parameters
    ----------

    network : Network

        The network in which to calculate the list of closed triads

    """
    c_triads: set = set()
    edges = set()

    # Collect all edges of successors
    for x in g.successors(v):
        for y in g.successors(x):
            edges.add((x, y))

    for x, y in edges:
        if y in g.successors(v):
            c_triads.add((x, y))
    return c_triads