Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhanced graphical visualization through the use of interactive displays (Pyvis) #249

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

Thomas-aub
Copy link

Overview

We've extended the graph visualization functionality to support interactive visualization using the Pyvis library while maintaining full compatibility with the existing NetworkX implementation. This enhancement allows users to explore and interact with graphs in a HTML-based interface, particularly beneficial for analyzing smaller or sparse networks.

Details of the Changes

  • Interactive Visualization with Pyvis

    • The function now supports Pyvis as an alternative rendering method.
    • By default, the visualization remains based on NetworkX, ensuring no breaking changes.
    • Users can opt for an interactive HTML visualization by setting specific parameters.
    • The Pyvis library is well-documented and actively maintained.
  • Refactoring & Documentation

    • Network visualization functions have been split into static and interactive rendering for better maintainability.
    • Documentation has been updated to reflect this new feature.
    • Pyvis has been added to the necessary dependency files.

Performance Considerations

  • Effectiveness on Small & Sparse Graphs
    • The interactive visualization is particularly useful for sparse graphs, allowing users to navigate and highlight specific clusters.
  • Scalability Limitations
    • On very large graphs, the interactive visualization becomes cluttered and difficult to interpret, similar to the existing NetworkX visualization.

The changes maintain the existing API while adding powerful new visualization capabilities. The Pyvis library was chosen for its robust documentation and active maintenance, making it a reliable long-term solution for interactive graph visualization.

…ng tests

- Enhanced the `plot_network_clusters` function with support for interactive graph visualizations using the Pyvis library.
  - Introduced the `interractive` argument (default: `False`) to toggle between static and interactive modes.
  - Added support for saving interactive visualizations to an HTML file (`output_file` argument, default: "interactive.html").
  - Enabled dynamic handling of node sizes, labels, edge widths, and edge weights in the interactive mode.

- Updated the unit tests in `test_viz_network.py`:
  - Added `test_interactive_cluster` to validate interactive visualization generation.
  - Ensured that the generated HTML file is created and removed cleanly after the test.
- Updated dependencies across the project to include pyvis:
  - Added `pyvis` to `requirements.docs.txt` for documentation builds.
  - Added `pyvis` to `requirements.txt` for documentation builds.
  - Added `pyvis` to `environment.yml` for Conda environments.
  - Added `pyvis` to `conda/meta.yaml` for Conda packaging.

This ensures that the Pyvis library is properly integrated for supporting interactive graph visualizations.
…ctive functions

The network visualization code has been restructured to improve maintainability
and separation of concerns:
- Extract static matplotlib rendering into _draw_static_network()
- Extract interactive Pyvis rendering into _draw_interactive_network()
- Simplify main plot_network_clusters() function to handle common initialization
  and delegation

Benefits:
- Better code organization and reduced complexity
- Easier to maintain and debug each rendering mode separately
- Simplified testing of each visualization method
- Reduced cyclomatic complexity of main function

No breaking changes to the public API.
- Restructured networks.py for better readability and organization.
- Fixed and enhanced function documentation for improved clarity.
- Introduced physics buttons to control interactive graph behavior.
  - Added buttons to toggle physics simulation (e.g., enable/disable).
  - Enhanced user interaction by allowing physics adjustments in real-time.

- Implemented a selection menu for graph elements:
  - Added a dropdown menu for selecting nodes or clusters in the visualization.
  - Provided easy navigation and manipulation of graph elements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants