summaryrefslogtreecommitdiff
path: root/graph
diff options
context:
space:
mode:
Diffstat (limited to 'graph')
-rw-r--r--graph/Makefile.am15
-rw-r--r--graph/src/adlist.rs8
-rw-r--r--graph/src/labelled.rs2
3 files changed, 20 insertions, 5 deletions
diff --git a/graph/Makefile.am b/graph/Makefile.am
index 776b911..623572a 100644
--- a/graph/Makefile.am
+++ b/graph/Makefile.am
@@ -1,12 +1,19 @@
-.PHONY: dev rel
+.PHONY: dev rel clean check
all: dev
dev:
- @CARGO@ build
+ @echo "cargo build"
+ @@CARGO@ build
rel:
- @CARGO@ build --release
+ @echo "cargo build --release"
+ @@CARGO@ build --release
clean:
- @CARGO@ clean
+ @echo "cargo clean"
+ @@CARGO@ clean
+
+check:
+ @echo "cargo clippy"
+ @@CARGO@ clippy
diff --git a/graph/src/adlist.rs b/graph/src/adlist.rs
index c16ceb2..18ad770 100644
--- a/graph/src/adlist.rs
+++ b/graph/src/adlist.rs
@@ -102,6 +102,14 @@ impl ExtGraph for ALGraph {
}
}
+// TODO: Add a way to build a graph by its raw adjacency list representation.
+impl From<Vec<Vec<usize>>> for ALGraph {
+ fn from(adlist: Vec<Vec<usize>>) -> Self {
+ let nodes: Vec<ALNode> = adlist.iter().cloned().map(ALNode::new).collect();
+ Self { nodes }
+ }
+}
+
#[cfg(test)]
mod algraph_test {
use super::*;
diff --git a/graph/src/labelled.rs b/graph/src/labelled.rs
index 1cb2461..d02e301 100644
--- a/graph/src/labelled.rs
+++ b/graph/src/labelled.rs
@@ -144,7 +144,7 @@ impl<'a> Iterator for LabelIndexIter<'a> {
#[inline]
fn next(&mut self) -> Option<Self::Item> {
- self.iter.as_mut().map(|iterator| iterator.next()).flatten()
+ self.iter.as_mut().and_then(|iterator| iterator.next())
}
#[inline]