Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undirected graphs not supported? #23

Open
samuller opened this issue Feb 18, 2025 · 0 comments
Open

Undirected graphs not supported? #23

samuller opened this issue Feb 18, 2025 · 0 comments

Comments

@samuller
Copy link

I get the following compiler error when trying to use fdg::init_force_graph_uniform with a graph defined as StableGraph<(), (), Undirected>:

18 |     let mut force_graph: fdg::ForceGraph<f32, 3,(), ()> = fdg::init_force_graph_uniform(graph, 10.0);
   |                                                           ----------------------------- ^^^^^ the trait `From<StableGraph<(), (), Undirected>>` is not implemented for `StableGraph<_, _>`, which is required by `StableGraph<(), (), Undirected>: Into<StableGraph<_, _>>`
   |                                                           |
   |                                                           required by a bound introduced by this call

Here's example code that reproduces the issue:

use fdg::{petgraph::{prelude::{StableGraph, StableUnGraph}, Undirected}, Force};

fn main() {
    let mut graph: StableGraph<(), (), Undirected> = StableGraph::default();
    // let mut graph: StableUnGraph<(), ()> = StableGraph::default();
    // Add nodes to the graph
    let mut nodes = Vec::new();
    nodes.push(graph.add_node(()));
    nodes.push(graph.add_node(()));
    nodes.push(graph.add_node(()));
    nodes.push(graph.add_node(()));
    // Add edges
    graph.add_edge(nodes[0], nodes[1], ());
    graph.add_edge(nodes[1], nodes[2], ());
    graph.add_edge(nodes[2], nodes[3], ());
    println!("{:?}", graph);

    let mut force_graph: fdg::ForceGraph<f32, 3,(), ()> = fdg::init_force_graph_uniform(graph, 10.0);
    fdg::simple::Center::default().apply(&mut force_graph);
}

I'm currently using v1.0.0, i.e. my Cargo.toml contains this:

[dependencies]
fdg = { git = "https://github.com/grantshandy/fdg", version = "1.0.0" }

Are undirected graphs supposed to be supported, or is the algo somehow limited to directed graphs?

BTW, thanks for the awesome library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant