viz
class NetworkLayout(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)
Bases: StrEnum
, Enum
KamadaKawai = ‘kamada_kawai_layout’
Spectral = ‘spectral_layout’
Spring = ‘spring_layout’
compute_layout(G, layout=, weight=‘weight’, seed=1234)
Function to compute the optimal layout for a graph network.
Parameters
G : Graph Network to draw.
layout : Layout algorithm to use. Defaults to nx.spring_layout.
weight : Edges weight to use while computing the layout. Defaults to “weight”.
seed : Random seed. Defaults to 1234.
Returns
pos : Layout positions that can be reused for replotting of the same network.
create_cmap_from_list(array)
Function to create a cmap from a list of values (corresponding to a condition for each subject.) For example, subject with value = 0 will be mapped black, whereas subject = >1 will be mapped to different colors.
Parameters
array : Array of integers corresponding to condiditions (can be binary also.).
Returns
cmap : List containing all colors.
creating_node_colormap(percentile_dict)
Function to create a colormap for a set of nodes based on a percentile dictionary.
Parameters
percentile_dict : Percentile dictionary with keys identifying clusters.
Returns
cmap : List containing all colors.
membership_distribution(mat, output=’./membership_distribution.png’)
Function returning a plot of the distribution of the maximum membership values for each subject and the delta plot of the difference with the second highest membership from the fuzzy c-partitioned matrix.
Parameters
mat : Membership fuzzy c-partitioned matrix.
output : Output filename and path. Defaults to “./membership_distribution.png”.
set_nodes_position(G, pos)
Function to set the nodes’ position for a graph network.
Position array has to be converted into python float in order for Gephi file format export.
Parameters
G : Graph Network to draw.
pos : Dictionary with nodes’ positions.
Returns
G : Network with nodes’ positions set.
visualize_network(G, output, weight=‘weight’, centroids_labelling=True, subjects_labelling=False, centroid_node_shape=500, centroid_alpha=1, centroid_node_color=‘white’, centroid_edge_color=‘black’, subject_node_shape=5, subject_alpha=0.3, subject_node_color=‘black’, subject_edge_color=None, colormap=‘plasma’, title=‘Graph Network’, legend_title=‘Membership values’)
Function to visualize a weighted undirected graph network. Based on the concept from: Ariza-Jiménez, L., Villa, L. F., & Quintero, O. L. (2019). Memberships
Networks for High-Dimensional Fuzzy Clustering Visualization., Applied Computer Sciences in Engineering (Vol. 1052, pp. 263–273). Springer International Publishing. https://doi.org/10.1007/978-3-030-31019-6_23
Parameters
G : Graph Network to draw.
output : Filename and path for the output png image.
weight : Edge attribute to use as weight. Defaults to “weight”.
centroids_labelling : Label centroid nodes. Defaults to True.
subjects_labelling : Label subject nodes. Defaults to False.
centroid_node_shape : Centroid’s nodes shape. Defaults to 500.
centroid_alpha : Centroid’s nodes alpha. Defaults to 1.
centroid_node_color : Centroid’s nodes color. Defaults to “white”.
centroid_edge_color : Centroid’s nodes edge color. Defaults to “black”.
subject_node_shape : Subject’s nodes shape. Defaults to 5.
subject_alpha : Subject’s nodes alpha value. Defaults to 0.3.
subject_node_color : Subject’s nodes color. Defaults to “black”.
subject_edge_color : Subject’s nodes edge color. Defaults to None.
colormap : Colormap to use to draw edges’ weights. Defaults to “plasma”.
title : Graph title. Defaults to “Graph Network”.
legend_title : Legend title. Defaults to “Membership values”.