egui_graphs
Grpah visualization implementation using egui
Status
The project is close to the first stable version.
Currently not optimized for large graphs. The goal is to match egui drawing speed. Further optimizations are unnecessary.
Concept
The goal is to create a crate that expands egui's visualization capabilities and offers an easy-to-integrate, customizable graph visualization widget.
- Customization and interactivity;
- Ability to draw arbitrarily complex graphs with self-references, loops, etc.;
- Widget does not modify the provided graph and properties; instead, it generates changes, in case of any interactions, which the client can apply.
Roadmap for v0.1.0 - first stable release
Examples
Basic
Step 1: Setting up the ExampleApp struct.
First, let's define the ExampleApp
struct that will hold the graph elements and settings. The struct contains two fields: elements
and settings
. The elements field stores the graph's nodes and edges, while settings contains the configuration options for the GraphView widget.
Step 2: Implementing the new() function.
Next, implement the new()
function for the ExampleApp
struct. This function initializes the graph settings with default values and generates the graph elements.
Step 3: Generating the graph elements.
Create a helper function called generate_graph()
that initializes the nodes and edges for the graph. In this example, we create three nodes with unique positions and three edges connecting them in a triangular pattern.
Step 4: Implementing the update() function.
Now, implement the update()
function for the ExampleApp
. This function creates a GraphView
widget with the elements
and settings
, and adds it to the central panel using the ui.add()
function.
Step 5: Running the application.
Finally, run the application using the run_native()
function with the specified native options and the ExampleApp
.
You can further customize the appearance and behavior of your graph by modifying the settings or adding more nodes and edges as needed. Don't forget to apply changes returned from the widget.
Interactive
You can check more advanced interactive example for usage references, settings description and changes apply demonstration.