pyKrack

Computing Krackhardt hierarchy score on netowrkX graphs

Install

Due to the comparisons with the R package sna we recommend using conda to manage your environment.

  1. First create the pykrack conda environment from the environment.yml file:
conda (or mamba) env create -f environment.yml
  1. Then load the conda environment with:
conda activate pykrack
  1. And finally install the package from pip via the following command:
pip install pyKrack

Alternatively pyKrack can also be isntalled using pip via the following command

pip install pyKrack

Then install the R dependencies listed in the conda environmnet.yml manually.

How to use

Please see the core and hierarchy notebooks for more detailed explanations.

pyKrack consists of one main function, compute_hierarchy.


source

compute_hierarchy

 compute_hierarchy (G, metric='pykrack')

Compute one of the possible hierarchy scores

Type Default Details
G Directed NetworkX graph
metric str pykrack Type of hierarchy metric to compute. Accepted types are:
‘pykrack’ for this module’s implementation of the Krackhardt score.
‘rsnakrack’ for the sna implementation in R.
‘hierarchy_flow’ for the Luo and Magee 2011 as implemented in the NetworkX package.
Returns float One of the possible hierarchy scores