GRAPHY
This project is a web application built with Dash and NetworkX that allows users to visualize random graphs using various graph generation algorithms. Users can interactively select the graph type, layout algorithm, number of nodes, and number of edges to generate and visualize the graph.
I created Graphy primarily out of curiosity about graph theory and its practical applications. The project aims to visualize various types of graphs using NetworkX, Dash, and Plotly. It's a simple yet effective tool for generating and exploring graphs like Erdős-Rényi, Barabási-Albert, and Watts-Strogatz networks.
Admittedly, the implementation is basic; it's a pretty lazy project with ample room for improvement. Nonetheless, Graphy serves as a practical exercise in applying graph theory concepts in a visual context. Future iterations may focus on enhancing the user interface, adding more graph types, and exploring advanced graph algorithms.
- Erdős-Rényi
- Barabási-Albert
- Watts-Strogatz
- Random Geometric
- Connected Caveman
- Spring Layout
- Circular Layout
- Random Layout
- Kamada-Kawai Layout
- Fruchterman-Reingold Layout
- Dropdowns for selecting graph type and layout algorithm
- Input fields for specifying the number of nodes and edges
- Nodes colored based on degree centrality
- Edge visualization with hover information
- Clone the repository:
git clone https://github.com/RuntimeConnoisseurs/GRAPHY.git
- Navigate into the project directory:
- Install the required Python packages:
pip install -r requirements.txt
or runpip install networkx dash dash-core-components dash-html-components plotly
-
Start the application by navigating into the project directory and running this command
python app.py
-
Open a web browser and go to
http://localhost:8050
to view the application.
Default view once the webpage is launched:
Another View with Circular Layout: When an error occur it is highhlighted and a pop-up is produced: Another Look with Watts-Strogatz Graph and Kamada Kawai Layout: A Random Geometric Graph: Hovering Over a Node shows its Degree Cardinality:Here is a demonstration of the project web page in action:
- Erdős-Rényi Graph (erdos_renyi):
- Parameters:
- num_nodes: int - Number of nodes in the graph.
- num_edges: float - Probability for edge creation. In NetworkX, this parameter represents the probability of an edge between any pair of nodes.
- Modification:
- The function uses nx.erdos_renyi_graph(num_nodes, num_edges) where num_edges serves as the probability for edge creation.
- Barabási-Albert Graph (barabasi_albert):
- Parameters:
- num_nodes: int - Number of nodes in the graph.
- num_edges: int - Number of edges to attach from a new node to existing nodes (m parameter).
- Modification:
- Checks if num_edges is a float, converting it to int if necessary before creating the graph with nx.barabasi_albert_graph(num_nodes, num_edges).
- Watts-Strogatz Graph (watts_strogatz):
- Parameters:
- num_nodes: int - Number of nodes in the graph.
- num_edges: int - Each node is joined with its k nearest neighbors in a ring topology (k parameter).
- p: float - Probability of rewiring each edge (default set to 0.3).
- Modification:
- Converts num_edges to int if it's a float before creating the graph with nx.watts_strogatz_graph(num_nodes, num_edges, p=0.3).
- Random Geometric Graph (random_geometric):
- Parameters:
- num_nodes: int or iterable - Number of nodes or iterable of nodes.
- radius: float - Distance threshold value (default set to 0.3).
- Modification:
- Creates the graph using nx.random_geometric_graph(num_nodes, radius=0.3), where radius determines the distance threshold for connecting nodes.
- Connected Caveman Graph (connected_caveman):
- Parameters:
- num_nodes: int - Number of nodes in the graph.
- num_edges: int - Number of edges per clique (l * (k-1) where l is the number of cliques and k is the size of cliques).
- Modification:
- Adjusts num_edges to an integer if it's a float, then calculates the number of edges per clique (num_edges // num_nodes) before creating the graph with nx.connected_caveman_graph(num_nodes, num_edges // num_nodes).
Users can manually access additional graph definitions in NetworkX by exploring the official documentation or specific graph types that require parameters not covered in this function. Graph Generators Networkx
Contributions are welcome! If you have suggestions, feature requests, or bug reports, please open an issue or submit a pull request. Please note that responses may be delayed as I am not always actively monitoring this repository.
- Improving the UI/UX to make it more fluid.
- Add more Graph types and Graph layout, will need to have a deeper understanding of graph systems.
- Provide an example use cases ie., case studies.
- Allow for custom use input through files like GML,CSV,LEDA and others which would allow for custom graphs to be visualised.
- Proper Error Handling.
This project is licensed under the MIT License - see the LICENSE file for details.