nicer iteration
This commit is contained in:
parent
0a548bbd32
commit
b6ab0f2144
|
@ -36,6 +36,13 @@ fn layout_from_edge_list(
|
||||||
let mut edge_matrix = graph::new_edge_matrix(number_of_nodes);
|
let mut edge_matrix = graph::new_edge_matrix(number_of_nodes);
|
||||||
match edges.extract::<&PyIterator>() {
|
match edges.extract::<&PyIterator>() {
|
||||||
Ok(iter) => {
|
Ok(iter) => {
|
||||||
|
iter.iter()?
|
||||||
|
.map(|edge| edge.and_then(PyAny::extract::<(usize, usize)>))
|
||||||
|
.for_each(|edge| {
|
||||||
|
if let Ok((u, v)) = edge {
|
||||||
|
graph::add_edge(&mut edge_matrix, u, v);
|
||||||
|
}
|
||||||
|
});
|
||||||
for edge in iter {
|
for edge in iter {
|
||||||
let edge = edge?;
|
let edge = edge?;
|
||||||
let edge = edge.extract::<(usize, usize)>()?;
|
let edge = edge.extract::<(usize, usize)>()?;
|
||||||
|
|
Loading…
Reference in New Issue