Skip to content

strength_dir not matching output with description #133

@MartaMorandini

Description

@MartaMorandini

In the function strength_dir there should be 3 outputs (in-strength, out-strength and in + out), but the function returns only the sum of the in plus out strength.
Here is the modified version adding the missing outputs.

def strengths_dir(CIJ):
    '''
    Node strength is the sum of weights of links connected to the node. The
    instrength is the sum of inward link weights and the outstrength is the
    sum of outward link weights.

    Parameters
    ----------
    CIJ : NxN np.ndarray
        directed weighted connection matrix

    Returns
    -------
    is : Nx1 np.ndarray
        node in-strength
    os : Nx1 np.ndarray
        node out-strength
    str : Nx1 np.ndarray
        node strength (in-strength + out-strength)

    Notes
    -----
    Inputs are assumed to be on the columns of the CIJ matrix.
    '''
    istr = np.sum(CIJ, axis=0)
    ostr = np.sum(CIJ, axis=1)
    return istr, ostr, istr + ostr

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions