blitzarx1 / egui_graphs

Interactive graph visualization widget for rust powered by egui and petgraph
https://docs.rs/crate/egui_graphs
MIT License
419 stars 30 forks source link

Question: Is the Graph::from() function able to work with custom edges? #151

Closed Atlas16A closed 11 months ago

Atlas16A commented 11 months ago

Using the NodeShapeAnimated example I tried to apply a similar setup to edges but im getting a type error on every use of Graph::from() and is clear its trying to return one with a default edge.

   --> src/main.rs:540:16
    |
540 |             g: Graph::from(&g),
    |                ^^^^^^^^^^^^^^^ expected `Graph<(), (), ..., ..., ..., ...>`, found `Graph<_, _, Directed, u32, _>`
    |
    = note: expected struct `egui_graphs::Graph<(), (), _, _, node::NodeShape, edge::EdgeShape>`
               found struct `egui_graphs::Graph<_, _, _, _, _, egui_graphs::DefaultEdgeShape>`
blitzarx1 commented 11 months ago

Hey! Sorry for long response. You can check examples/custom_draw Graph::from is used there with NodeShapeAnimated. All you need to do is to explicitly set NodeShapeAnimated in the Graph signature. Please check example. If this does not help please post here your code with this error.

Atlas16A commented 11 months ago

Ah, I wasnt very clear, what i mean to say is that Ive already used NodeShapeAnimated and modified it some, what Im currently working on is EdgeShape and changing that, I copied the defaultedgeshape and applyed it to the same formating that NodeShapeAnimated has.

You can view my code here https://github.com/Atlas16A/LSegui/blob/master/src/main.rs The relevant lines are, 14-19, 517, and 946, in the main.rs file and 14, 25, and 41 in the edge.rs file.

My NodeShape works perfectly fine by itself however my EdgeShape creates the error above, when added, on all the Graph::from() functions.

blitzarx1 commented 11 months ago

Yep, this is the bug. I ' ve already fixed it. Please check master.