use petgraph::graphmap::DiGraphMap;

pub struct GraphBuilder;
pub struct Edge;

impl GraphBuilder {
    pub fn new() -> Self {
        Self {}
    }

    pub fn build(self) -> DiGraphMap<Mod, Edge> {
        DiGraphMap::new()
    }

    // TODO: add_crate_root();
    // TODO: add_mod();
    // TODO: add_dep();
}

#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct Mod;

#[cfg(test)]
mod tests {
    use super::*;
    use petgraph::graphmap::DiGraphMap;

    #[test]
    fn new_builder_produces_an_empty_directed_graph() {
        let builder = GraphBuilder::new();
        let graph: DiGraphMap<Mod, Edge> = builder.build();
        assert_eq!(0, graph.node_count());
        assert_eq!(0, graph.edge_count());
    }
}

use petgraph::graph::Graph as PetGraph;
use petgraph::Directed;

pub struct GraphBuilder;
pub struct Mod;
pub struct Edge;

impl GraphBuilder {
    pub fn new() -> Self {
        Self {}
    }

    pub fn build(self) -> PetGraph<Mod, Edge, Directed> {
        PetGraph::new()
    }

    // TODO: add_crate_root();
    // TODO: add_mod();
    // TODO: add_dep();
}

#[cfg(test)]
mod tests {
    use super::*;
    use petgraph::graph::Graph as PetGraph;
    use petgraph::Directed;

    #[test]
    fn new_builder_produces_an_empty_directed_graph() {
        let builder = GraphBuilder::new();
        let graph: PetGraph<Mod, Edge, Directed> = builder.build();
        assert_eq!(0, graph.node_count());
        assert_eq!(0, graph.edge_count());
    }
}

--- 
+++ 
@@ -1,8 +1,6 @@
-use petgraph::graph::Graph as PetGraph;
-use petgraph::Directed;
+use petgraph::graphmap::DiGraphMap;
 
 pub struct GraphBuilder;
-pub struct Mod;
 pub struct Edge;
 
 impl GraphBuilder {
@@ -10,8 +8,8 @@
         Self {}
     }
 
-    pub fn build(self) -> PetGraph<Mod, Edge, Directed> {
-        PetGraph::new()
+    pub fn build(self) -> DiGraphMap<Mod, Edge> {
+        DiGraphMap::new()
     }
 
     // TODO: add_crate_root();
@@ -19,16 +17,18 @@
     // TODO: add_dep();
 }
 
+#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
+pub struct Mod;
+
 #[cfg(test)]
 mod tests {
     use super::*;
-    use petgraph::graph::Graph as PetGraph;
-    use petgraph::Directed;
+    use petgraph::graphmap::DiGraphMap;
 
     #[test]
     fn new_builder_produces_an_empty_directed_graph() {
         let builder = GraphBuilder::new();
-        let graph: PetGraph<Mod, Edge, Directed> = builder.build();
+        let graph: DiGraphMap<Mod, Edge> = builder.build();
         assert_eq!(0, graph.node_count());
         assert_eq!(0, graph.edge_count());
     }
Use GraphMap instead of Graph

So that we can store data directly in nodes
