@@ -70,10 +70,14 @@ pub static Incoming: Direction = Direction { repr: 1 };
70
70
71
71
impl NodeIndex {
72
72
fn get ( & self ) -> uint { let NodeIndex ( v) = * self ; v }
73
+ /// Returns unique id (unique with respect to the graph holding associated node).
74
+ pub fn node_id ( & self ) -> uint { self . get ( ) }
73
75
}
74
76
75
77
impl EdgeIndex {
76
78
fn get ( & self ) -> uint { let EdgeIndex ( v) = * self ; v }
79
+ /// Returns unique id (unique with respect to the graph holding associated edge).
80
+ pub fn edge_id ( & self ) -> uint { self . get ( ) }
77
81
}
78
82
79
83
impl < N , E > Graph < N , E > {
@@ -201,39 +205,39 @@ impl<N,E> Graph<N,E> {
201
205
///////////////////////////////////////////////////////////////////////////
202
206
// Iterating over nodes, edges
203
207
204
- pub fn each_node ( & self , f : |NodeIndex , & Node < N > | -> bool ) -> bool {
208
+ pub fn each_node < ' a > ( & ' a self , f : |NodeIndex , & ' a Node < N > | -> bool ) -> bool {
205
209
//! Iterates over all edges defined in the graph.
206
210
self . nodes . iter ( ) . enumerate ( ) . advance ( |( i, node) | f ( NodeIndex ( i) , node) )
207
211
}
208
212
209
- pub fn each_edge ( & self , f : |EdgeIndex , & Edge < E > | -> bool ) -> bool {
213
+ pub fn each_edge < ' a > ( & ' a self , f : |EdgeIndex , & ' a Edge < E > | -> bool ) -> bool {
210
214
//! Iterates over all edges defined in the graph
211
215
self . edges . iter ( ) . enumerate ( ) . advance ( |( i, edge) | f ( EdgeIndex ( i) , edge) )
212
216
}
213
217
214
- pub fn each_outgoing_edge ( & self ,
215
- source : NodeIndex ,
216
- f : |EdgeIndex , & Edge < E > | -> bool )
217
- -> bool {
218
+ pub fn each_outgoing_edge < ' a > ( & ' a self ,
219
+ source : NodeIndex ,
220
+ f : |EdgeIndex , & ' a Edge < E > | -> bool )
221
+ -> bool {
218
222
//! Iterates over all outgoing edges from the node `from`
219
223
220
224
self . each_adjacent_edge ( source, Outgoing , f)
221
225
}
222
226
223
- pub fn each_incoming_edge ( & self ,
224
- target : NodeIndex ,
225
- f : |EdgeIndex , & Edge < E > | -> bool )
226
- -> bool {
227
+ pub fn each_incoming_edge < ' a > ( & ' a self ,
228
+ target : NodeIndex ,
229
+ f : |EdgeIndex , & ' a Edge < E > | -> bool )
230
+ -> bool {
227
231
//! Iterates over all incoming edges to the node `target`
228
232
229
233
self . each_adjacent_edge ( target, Incoming , f)
230
234
}
231
235
232
- pub fn each_adjacent_edge ( & self ,
233
- node : NodeIndex ,
234
- dir : Direction ,
235
- f : |EdgeIndex , & Edge < E > | -> bool )
236
- -> bool {
236
+ pub fn each_adjacent_edge < ' a > ( & ' a self ,
237
+ node : NodeIndex ,
238
+ dir : Direction ,
239
+ f : |EdgeIndex , & ' a Edge < E > | -> bool )
240
+ -> bool {
237
241
//! Iterates over all edges adjacent to the node `node`
238
242
//! in the direction `dir` (either `Outgoing` or `Incoming)
239
243
@@ -257,11 +261,11 @@ impl<N,E> Graph<N,E> {
257
261
// variables or other bitsets. This method facilitates such a
258
262
// computation.
259
263
260
- pub fn iterate_until_fixed_point ( & self ,
261
- op: |iter_index: uint ,
262
- edge_index : EdgeIndex ,
263
- edge : & Edge < E > |
264
- -> bool ) {
264
+ pub fn iterate_until_fixed_point < ' a > ( & ' a self ,
265
+ op: |iter_index: uint ,
266
+ edge_index : EdgeIndex ,
267
+ edge : & ' a Edge < E > |
268
+ -> bool ) {
265
269
let mut iteration = 0 ;
266
270
let mut changed = true ;
267
271
while changed {
0 commit comments