ProductPromotion
Logo

Rust

made by https://0x3d.site

GitHub - blitzarx1/egui_graphs: Interactive graph visualization widget for rust powered by egui and petgraph
Interactive graph visualization widget for rust powered by egui and petgraph - blitzarx1/egui_graphs
Visit Site

GitHub - blitzarx1/egui_graphs: Interactive graph visualization widget for rust powered by egui and petgraph

GitHub - blitzarx1/egui_graphs: Interactive graph visualization widget for rust powered by egui and petgraph

build Crates.io docs.rs

egui_graphs

Graph visualization with rust, petgraph and egui in its DNA.

Screenshot 2023-04-28 at 23 14 38

The project implements a Widget for the egui framework, enabling easy visualization of interactive graphs in rust. The goal is to implement the very basic engine for graph visualization within egui, which can be easily extended and customized for your needs.

  • Visualization of any complex graphs;
  • Zooming and panning;
  • Node and Edge labels;
  • Node and edges interactions and events reporting: click, double click, select, drag;
  • Style configuration via egui context styles;
  • Dark/Light theme support via egui context styles;
  • Events reporting to extend the graph functionality by the user handling them;
  • Layots and custom layout mechanism;

Status

The project is on track for a stable release v1.0.0. For the moment, breaking releases are very possible.

Please use master branch for the latest updates.

Check the demo example for the comprehensive overview of the widget possibilities.

Layouts

In addition to the basic graph display functionality, the project provides a layout mechanism to arrange the nodes in the graph. The Layout trait can be implemented by the library user allowing for custom layouts. The following layouts are coming from the box:

  • Random layout;
  • Hierarchical layout;
  • Force-directed layout; (coming soon)

Screenshot 2024-10-28 at 3 57 05 PM

Check the layouts example.

Examples

Basic setup example

The source code of the following steps can be found in the basic example.

Step 1: Setting up the BasicApp struct.

First, let's define the BasicApp struct that will hold the graph.

pub struct BasicApp {
    g: egui_graphs::Graph,
}

Step 2: Implementing the new() function.

Next, implement the new() function for the BasicApp struct.

impl BasicApp {
    fn new(_: &eframe::CreationContext<'_>) -> Self {
        let g = generate_graph();
        Self { g: egui_graphs::Graph::from(&g) }
    }
}

Step 3: Generating the graph.

Create a helper function called generate_graph(). In this example, we create three nodes and three edges.

fn generate_graph() -> petgraph::StableGraph<(), ()> {
    let mut g = petgraph::StableGraph::new();

    let a = g.add_node(());
    let b = g.add_node(());
    let c = g.add_node(());

    g.add_edge(a, b, ());
    g.add_edge(b, c, ());
    g.add_edge(c, a, ());

    g
}

Step 4: Implementing the eframe::App trait.

Now, lets implement the eframe::App trait for the BasicApp. In the update() function, we create a egui::CentralPanel and add the egui_graphs::GraphView widget to it.

impl eframe::App for BasicApp {
    fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
        egui::CentralPanel::default().show(ctx, |ui| {
            ui.add(&mut egui_graphs::GraphView::new(&mut self.g));
        });
    }
}

Step 5: Running the application.

Finally, run the application using the eframe::run_native() function.

fn main() {
    eframe::run_native(
        "egui_graphs_basic_demo",
        eframe::NativeOptions::default(),
        Box::new(|cc| Ok(Box::new(BasicApp::new(cc)))),
    )
    .unwrap();
}

Screenshot 2023-10-14 at 23 49 49 You can further customize the appearance and behavior of your graph by modifying the settings or adding more nodes and edges as needed.

Features

Events

Can be enabled with events feature. Events describe a change made in graph whether it changed zoom level or node dragging.

Combining this feature with custom node draw function allows to implement custom node behavior and drawing according to the events happening.

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory