Skip to content

Commit 5973936

Browse files
author
root
committed
Disable DfsIter and BfsIter until bug rust-lang/rust#22841 is fixed
rust-lang/rust#22841
1 parent 4f47404 commit 5973936

File tree

4 files changed

+8
-64
lines changed

4 files changed

+8
-64
lines changed

src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ pub use graph::Graph;
1919
pub use self::EdgeDirection::{Outgoing, Incoming};
2020
pub use visit::{
2121
Bfs,
22-
BfsIter,
2322
Dfs,
24-
DfsIter,
2523
};
2624

2725
mod scored;

src/visit.rs

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -257,34 +257,6 @@ impl<N, VM> Dfs<N, VM> where
257257
}
258258
}
259259

260-
/// An iterator for a depth first traversal of a graph.
261-
pub struct DfsIter<'a, G: 'a + Visitable>
262-
{
263-
graph: &'a G,
264-
dfs: Dfs<G::NodeId, G::Map>,
265-
}
266-
267-
impl<'a, G: Visitable> DfsIter<'a, G>
268-
{
269-
pub fn new(graph: &'a G, start: G::NodeId) -> Self
270-
{
271-
DfsIter {
272-
graph: graph,
273-
dfs: Dfs::new(graph, start)
274-
}
275-
}
276-
}
277-
278-
impl<'a, G: 'a + Visitable> Iterator for DfsIter<'a, G> where
279-
G: for<'b> NeighborIter<'b>,
280-
{
281-
type Item = G::NodeId;
282-
fn next(&mut self) -> Option<G::NodeId>
283-
{
284-
self.dfs.next(self.graph)
285-
}
286-
}
287-
288260
/// A breadth first search (BFS) of a graph.
289261
///
290262
/// Using a **Bfs** you can run a traversal over a graph while still retaining
@@ -373,32 +345,3 @@ pub fn visitor<G>(graph: &G, start: <G as Graphlike>::NodeId) -> Visitor<G> wher
373345
}
374346
*/
375347

376-
/// An iterator for a breadth first traversal of a graph.
377-
pub struct BfsIter<'a, G: 'a + Visitable>
378-
{
379-
graph: &'a G,
380-
bfs: Bfs<G::NodeId, G::Map>,
381-
}
382-
383-
impl<'a, G: Visitable> BfsIter<'a, G> where
384-
G::NodeId: Clone,
385-
{
386-
pub fn new(graph: &'a G, start: G::NodeId) -> Self
387-
{
388-
BfsIter {
389-
graph: graph,
390-
bfs: Bfs::new(graph, start)
391-
}
392-
}
393-
}
394-
395-
impl<'a, G: 'a + Visitable> Iterator for BfsIter<'a, G> where
396-
G::NodeId: Clone,
397-
G: for<'b> NeighborIter<'b>,
398-
{
399-
type Item = G::NodeId;
400-
fn next(&mut self) -> Option<G::NodeId>
401-
{
402-
self.bfs.next(self.graph)
403-
}
404-
}

tests/graphmap.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ extern crate petgraph;
33
use petgraph::{
44
GraphMap,
55
};
6-
use petgraph::visit::{
7-
DfsIter,
8-
};
96

107
use petgraph::algo::{
118
dijkstra,
@@ -87,8 +84,10 @@ fn dfs() {
8784
gr.add_edge(i, j, 1.);
8885
gr.add_edge(i, k, 2.);
8986

87+
/*
9088
assert_eq!(DfsIter::new(&gr, h).count(), 4);
9189
assert_eq!(DfsIter::new(&gr, i).count(), 4);
9290
assert_eq!(DfsIter::new(&gr, z).count(), 1);
91+
*/
9392
}
9493

tests/ograph.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ use std::iter::AdditiveIterator;
66
use petgraph::{
77
Graph,
88
Bfs,
9-
BfsIter,
109
Dfs,
11-
DfsIter,
1210
Incoming,
1311
Outgoing,
1412
Directed,
@@ -84,6 +82,7 @@ fn dfs() {
8482
gr.add_edge(i, j, 1.);
8583
gr.add_edge(i, k, 2.);
8684

85+
/*
8786
assert_eq!(DfsIter::new(&gr, h).count(), 4);
8887
8988
assert_eq!(DfsIter::new(&Reversed(&gr), h).count(), 1);
@@ -93,6 +92,7 @@ fn dfs() {
9392
assert_eq!(DfsIter::new(&gr, i).count(), 3);
9493
9594
assert_eq!(DfsIter::new(&AsUndirected(&gr), i).count(), 4);
95+
*/
9696

9797
}
9898

@@ -111,6 +111,7 @@ fn bfs() {
111111
gr.add_edge(i, j, 1.);
112112
gr.add_edge(i, k, 2.);
113113

114+
/*
114115
assert_eq!(BfsIter::new(&gr, h).count(), 4);
115116
116117
assert_eq!(BfsIter::new(&Reversed(&gr), h).count(), 1);
@@ -120,6 +121,7 @@ fn bfs() {
120121
assert_eq!(BfsIter::new(&gr, i).count(), 3);
121122
122123
assert_eq!(BfsIter::new(&AsUndirected(&gr), i).count(), 4);
124+
*/
123125

124126
let mut bfs = Bfs::new(&gr, h);
125127
let nx = bfs.next(&gr);
@@ -302,9 +304,11 @@ fn dijk() {
302304
g.add_edge(c, f, 11);
303305
g.add_edge(e, f, 6);
304306
println!("{:?}", g);
307+
/*
305308
for no in BfsIter::new(&g, a) {
306309
println!("Visit {:?} = {:?}", no, g.node_weight(no));
307310
}
311+
*/
308312

309313
let scores = dijkstra(&g, a, None, |gr, n| gr.edges(n).map(|(n, &e)| (n, e)));
310314
let mut scores: Vec<_> = scores.into_iter().map(|(n, s)| (g[n], s)).collect();

0 commit comments

Comments
 (0)