This repository provides tools to visualize graphs using Plotly. It supports both 2D and 3D visualizations with customizable layouts, node sizes, edge weights, and edge colors.
- Visualize graphs in 2D or 3D.
- Support for various layout algorithms (
graphviz
,spring
,spectral
,random
). - Customize node sizes, edge weights, and edge colors.
- Generate output as interactive HTML files.
-
Install Graphviz (for Ubuntu):
sudo apt-get install graphviz libgraphviz-dev pkg-config
-
Install Python dependencies:
pip install -r requirements.txt
To visualize a graph, run the main script with the following command-line arguments:
python main.py --layout <layout> --node_size <size> --output <output_file> --title <title>
--layout
: Specifies the layout algorithm for positioning the graph. Options:graphviz
,spring
,spectral
,random
. Default:graphviz
.--node_size
: Sets the size of the nodes. Default:20
.--output
: Specifies the output file name for the HTML visualization. Default:outputs/graphviz.html
.--title
: Sets the title for the visualization. Default:Graph Visualization
.
python main.py --layout graphviz --node_size 20 --output outputs/graphviz.html --title "2D Graph Visualization"
python main.py --layout spring --node_size 30 --output outputs/spring_3d.html --title "Spring Layout 3D Visualization"
You can add new layout options by extending the --layout
argument in the script and implementing the corresponding layout logic.
main.py
: The main script for visualizing graphs.plotly_visualize.py
: Helper functions for 2D and 3D visualizations.outputs/
: Directory for storing the generated HTML files.
Contributions are welcome! Feel free to open issues or create pull requests to improve this repository.
This project is licensed under the MIT License.
For more details on using Plotly with Graphviz, check out this Medium post.