hina.visualization +++++++++++++ Tutorial ======== The `visualization` module provides functions for visualizing heterogeneous interaction networks. Users can generate interactive plots that project bipartite networks onto specified layouts, optionally filter nodes based on group attributes, and display community structures with distinct node colors and positions. Currently, the module contains the `network_visualization.py` file, which includes: - `plot_hina`: Visualizes a bipartite network with customizable layout, optional node filtering, and optional edge pruning. - `plot_bipartite_clusters`: Visualizes a bipartite network with community structure by arranging nodes in a circular layout with colors and shapes that reflect cluster memberships. .. list-table:: Functions :header-rows: 1 * - Function - Description * - `plot_hina(B, layout='bipartite', group_name=[None, None], pruning_kwargs=None, NetworkX_kwargs=None) <#plot-hina>`_ - Visualizes a bipartite network with customizable layout, optional node filtering, and edge pruning. * - `plot_bipartite_clusters(G, noise_scale=3, radius=20., encode_labels=False, node_labels=True, edge_labels=False, scale_nodes_by_degree=False, node_scale=2000., node_kwargs={'edgecolors':'black'}, edge_kwargs={'edge_color':'black'}) <#plot-bipartite-clusters>`_ - Visualizes a bipartite network with community structure; nodes are arranged in a circular layout according to cluster assignments. Reference --------- .. _plot-hina: .. raw:: html
function plot_hina(B, layout='bipartite', group_name=[None, None], pruning_kwargs=None, NetworkX_kwargs=None) [source]
**Description**: Visualizes a bipartite network using a specified layout. The function optionally prunes edges based on statistical significance if pruning parameters are provided and can filter nodes by a specified group attribute. **Parameters**: .. raw:: html
(B, layout='bipartite', group_name=[None, None], pruning_kwargs=None, NetworkX_kwargs=None)
**Returns**: - **None**: Displays the bipartite network visualization. .. _plot-bipartite-clusters: .. raw:: html
function plot_bipartite_clusters(G, noise_scale=3, radius=20., encode_labels=False, node_labels=True, edge_labels=False, scale_nodes_by_degree=False, node_scale=2000., node_kwargs={'edgecolors':'black'}, edge_kwargs={'edge_color':'black'}) [source]
**Description**: Visualizes a bipartite network with community structure by arranging nodes in a circular layout. Nodes in the first set are positioned around community centroids while nodes in the second set are arranged inside the circle. Community labels are indicated through distinct node colors and shapes. **Parameters**: .. raw:: html
(G, noise_scale=3, radius=20., encode_labels=False, node_labels=True, edge_labels=False, scale_nodes_by_degree=False, node_scale=2000., node_kwargs={'edgecolors':'black'}, edge_kwargs={'edge_color':'black'})
**Returns**: - **None**: Displays the network visualization with community grouping. Demo ==== Example Code ------------ This example demonstrates how to visualize a heterogeneous interaction network and its community structure. **Step 1: Import necessary libraries** .. code-block:: python import pandas as pd from hina.construction import get_bipartite from hina.visualization import plot_hina, plot_bipartite_clusters **Step 2: Load the example dataset. (The required spreadsheet file example_dataset.xlsx is in the Example_dataset directory.)** .. code-block:: python df = pd.read_excel("example_dataset.xlsx") **Step 3: Construct the bipartite network representation** .. code-block:: python B = get_bipartite(df,student_col='student id (student_col)', object_col='codes (obj1_col)', attr_col='code_categories (obj_attribute_col)', group_col='group (group_col)') **Step 4: Visualize the bipartite network for all groups** .. code-block:: python plot_hina(B, layout='bipartite', group_name = ['group (group_col)', None], pruning_kwargs=None, NetworkX_kwargs=None) **Step 5: Visualize bipartite clustering network with an automatically inferred number of communities** .. code-block:: python plot_bipartite_clusters(B) Example Output -------------- .. image:: Figures/visualization_demo_1.png :alt: Visualization Demo 1 :align: center :width: 50% Bipartite network of students and tasks for all groups. .. image:: Figures/visualization_demo_2.png :alt: Visualization Demo 4 :align: center :width: 50% Bipartite clustering network with automatically inferred communities. Paper Source ============ If you use these visualization functions in your work, please cite: Feng, S., Gibson, D., & Gasevic, D. (2025). Analyzing students' emerging roles based on quantity and heterogeneity of individual contributions in small group online collaborative learning using bipartite network analysis. Journal of Learning Analytics, 12(1), 253–270.