@@ -71,8 +71,8 @@ fn make_edges(scale: uint, edgefactor: uint) -> [(node_id, node_id)] {
71
71
( i, j)
72
72
}
73
73
else {
74
- let i = i * 2 ;
75
- let j = j * 2 ;
74
+ let i = i * 2i64 ;
75
+ let j = j * 2i64 ;
76
76
let scale = scale - 1 u;
77
77
78
78
let x = r. gen_float ( ) ;
@@ -83,28 +83,30 @@ fn make_edges(scale: uint, edgefactor: uint) -> [(node_id, node_id)] {
83
83
else {
84
84
let x = x - A ;
85
85
if x < B {
86
- choose_edge ( i + 1 , j, scale, r)
86
+ choose_edge ( i + 1i64 , j, scale, r)
87
87
}
88
88
else {
89
89
let x = x - B ;
90
90
if x < C {
91
- choose_edge ( i, j + 1 , scale, r)
91
+ choose_edge ( i, j + 1i64 , scale, r)
92
92
}
93
93
else {
94
- choose_edge ( i + 1 , j + 1 , scale, r)
94
+ choose_edge ( i + 1i64 , j + 1i64 , scale, r)
95
95
}
96
96
}
97
97
}
98
98
}
99
99
}
100
100
101
101
vec:: from_fn ( ( 1 u << scale) * edgefactor) { |_i|
102
- choose_edge ( 0 , 0 , scale, r)
102
+ choose_edge ( 0i64 , 0i64 , scale, r)
103
103
}
104
104
}
105
105
106
106
fn make_graph ( N : uint , edges : [ ( node_id , node_id ) ] ) -> graph {
107
- let graph = vec:: from_fn ( N ) { |_i| map:: int_hash ( ) } ;
107
+ let graph = vec:: from_fn ( N ) { |_i|
108
+ map:: hashmap :: < node_id , ( ) > ( { |x| x as uint } , { |x, y| x == y } )
109
+ } ;
108
110
109
111
vec:: each ( edges) { |e|
110
112
let ( i, j) = e;
@@ -119,16 +121,16 @@ fn make_graph(N: uint, edges: [(node_id, node_id)]) -> graph {
119
121
}
120
122
121
123
fn gen_search_keys ( graph : graph , n : uint ) -> [ node_id ] {
122
- let keys = map:: int_hash ( ) ;
124
+ let keys = map:: hashmap :: < node_id , ( ) > ( { |x| x as uint } , { |x , y| x == y } ) ;
123
125
let r = rand:: rng ( ) ;
124
126
125
127
while keys. size ( ) < n {
126
- let k = r. gen_u64 ( ) % graph. len ( ) as node_id ;
128
+ let k = r. gen_uint_range ( 0 u , graph. len ( ) ) ;
127
129
128
130
if graph[ k] . len ( ) > 0 u && vec:: any ( graph[ k] ) { |i|
129
- i != k
131
+ i != k as node_id
130
132
} {
131
- map:: set_add ( keys, k) ;
133
+ map:: set_add ( keys, k as node_id ) ;
132
134
}
133
135
}
134
136
map:: vec_from_set ( keys)
@@ -139,7 +141,7 @@ fn gen_search_keys(graph: graph, n: uint) -> [node_id] {
139
141
Nodes that are unreachable have a parent of -1." ]
140
142
fn bfs ( graph : graph , key : node_id ) -> bfs_result {
141
143
let marks : [ mut node_id ]
142
- = vec:: to_mut ( vec:: from_elem ( vec:: len ( graph) , -1 ) ) ;
144
+ = vec:: to_mut ( vec:: from_elem ( vec:: len ( graph) , -1i64 ) ) ;
143
145
144
146
let Q = create_queue ( ) ;
145
147
@@ -150,7 +152,7 @@ fn bfs(graph: graph, key: node_id) -> bfs_result {
150
152
let t = Q . pop_front ( ) ;
151
153
152
154
graph[ t] . each ( ) { |k|
153
- if marks[ k] == -1 {
155
+ if marks[ k] == -1i64 {
154
156
marks[ k] = t;
155
157
Q . add_back ( k) ;
156
158
}
@@ -226,7 +228,7 @@ fn bfs2(graph: graph, key: node_id) -> bfs_result {
226
228
// Convert the results.
227
229
vec:: map( colors) { |c|
228
230
alt c {
229
- white { -1 }
231
+ white { -1i64 }
230
232
black( parent) { parent }
231
233
_ { fail "Found remaining gray nodes in BFS " }
232
234
}
@@ -301,7 +303,7 @@ fn pbfs(graph: graph, key: node_id) -> bfs_result {
301
303
// Convert the results.
302
304
par:: map ( colors) { |c|
303
305
alt c {
304
- white { -1 }
306
+ white { -1i64 }
305
307
black ( parent) { parent }
306
308
_ { fail "Found remaining gray nodes in BFS" }
307
309
}
@@ -326,7 +328,7 @@ fn validate(edges: [(node_id, node_id)],
326
328
let mut parent = parent;
327
329
let mut path = [ ] ;
328
330
329
- if parent == -1 {
331
+ if parent == -1i64 {
330
332
// This node was not in the tree.
331
333
-1
332
334
}
@@ -354,7 +356,7 @@ fn validate(edges: [(node_id, node_id)],
354
356
log ( info, "Verifying tree edges..." ) ;
355
357
356
358
let status = tree. alli ( ) { |k, parent|
357
- if parent != root && parent != -1 {
359
+ if parent != root && parent != -1i64 {
358
360
level[ parent] == level[ k] - 1
359
361
}
360
362
else {
@@ -387,11 +389,12 @@ fn validate(edges: [(node_id, node_id)],
387
389
log ( info, "Verifying tree and graph edges..." ) ;
388
390
389
391
let status = par:: alli ( tree) { |u, v|
390
- if v == -1 || u as int == root {
392
+ let u = u as node_id ;
393
+ if v == -1i64 || u == root {
391
394
true
392
395
}
393
396
else {
394
- edges. contains ( ( u as int , v) ) || edges. contains ( ( v, u as int ) )
397
+ edges. contains ( ( u, v) ) || edges. contains ( ( v, u) )
395
398
}
396
399
} ;
397
400
0 commit comments