Skip to content

Undirected graphs not supported? #23

@samuller

Description

@samuller

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions