Working from the cost posted here we can easily calculate flexibility of each node across slices.
membership_df.apply(flexibility_index, axis=1)
where membership_df
is a pandas
DataFrame
as explained in this post.
Please note that it is not clear how you would like to deal with the “missing” nodes that have a membership of NaN
in a particular slice. In the code above this is implicitly treated as a “change” across slices, but perhaps you would like to deal with it differently. For example, you could simply not count any comparison with a NaN
as a change and divide by the number of comparisons you would then like to make.