Skip to content

Commit b4ff1cd

Browse files
committed
DistanceChange -> FrontierSize
1 parent 2d041a2 commit b4ff1cd

File tree

5 files changed

+31
-19
lines changed

5 files changed

+31
-19
lines changed

algo/src/visits/breadth_first/mod.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,19 @@ pub enum EventPred {
5656
/// The predecessor of [node](`EventPred::Known::node`).
5757
pred: usize,
5858
},
59-
/// The nodes at new distance are being processed.
59+
/// The size of the frontier at a given distance.
6060
///
61-
/// Note that this event is emitted either just before starting to visit nodes at
62-
/// a given distance or when all nodes at that distance have been visited depending
61+
/// This even will happen with increasing value of
62+
/// [`distance`](`EventPred::FrontierSize::distance`), starting at 0.
63+
///
64+
/// If the root is formed by a single node, this is the size of the sphere
65+
/// with center at the root and radius
66+
/// [`distance`](`EventPred::FrontierSize::distance`).
67+
///
68+
/// This event will happen just before starting to visit nodes at a given
69+
/// distance or when all nodes at that distance have been visited, depending
6370
/// on the implementation.
64-
DistanceChanged {
71+
FrontierSize {
6572
/// The number of nodes visited at that distance.
6673
nodes: usize,
6774
/// The distance of the nodes visited.
@@ -117,12 +124,19 @@ pub enum EventNoPred {
117124
/// The current node.
118125
node: usize,
119126
},
120-
/// The nodes at new distance are being processed.
127+
/// The size of the frontier at a given distance.
128+
///
129+
/// This even will happen with increasing value of
130+
/// [`distance`](`EventPred::FrontierSize::distance`), starting at 0.
131+
///
132+
/// If the root is formed by a single node, this is the size of the sphere
133+
/// with center at the root and radius
134+
/// [`distance`](`EventPred::FrontierSize::distance`).
121135
///
122-
/// Note that this event is emitted either just before starting to visit nodes at
123-
/// a given distance or when all nodes at that distance have been visited depending
136+
/// This event will happen just before starting to visit nodes at a given
137+
/// distance or when all nodes at that distance have been visited, depending
124138
/// on the implementation.
125-
DistanceChanged {
139+
FrontierSize {
126140
/// The number of nodes visited at that distance.
127141
nodes: usize,
128142
/// The distance of the nodes visited.

algo/src/visits/breadth_first/par_fair.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl<G: RandomAccessGraph + Sync> Parallel<EventNoPred> for ParFair<G, false> {
190190
while !curr_frontier.is_empty() {
191191
callback(
192192
&mut init,
193-
EventNoPred::DistanceChanged {
193+
EventNoPred::FrontierSize {
194194
distance,
195195
nodes: curr_frontier.len(),
196196
},
@@ -299,7 +299,7 @@ impl<G: RandomAccessGraph + Sync> Parallel<EventPred> for ParFair<G, true> {
299299
while !curr_frontier.is_empty() {
300300
callback(
301301
&mut init,
302-
EventPred::DistanceChanged {
302+
EventPred::FrontierSize {
303303
distance,
304304
nodes: curr_frontier.len(),
305305
},

algo/src/visits/breadth_first/par_low_mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ impl<G: RandomAccessGraph + Sync> Parallel<EventPred> for ParLowMem<G> {
179179
while !curr_frontier.is_empty() {
180180
callback(
181181
&mut init,
182-
EventPred::DistanceChanged {
182+
EventPred::FrontierSize {
183183
distance: distance - 1,
184184
nodes: curr_frontier.len(),
185185
},

algo/src/visits/breadth_first/seq.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<G: RandomAccessGraph> Sequential<EventPred> for Seq<G> {
166166

167167
callback(
168168
&mut init,
169-
EventPred::DistanceChanged {
169+
EventPred::FrontierSize {
170170
distance: 0,
171171
nodes: self.queue.len(),
172172
},
@@ -218,7 +218,7 @@ impl<G: RandomAccessGraph> Sequential<EventPred> for Seq<G> {
218218
if !self.queue.is_empty() {
219219
callback(
220220
&mut init,
221-
EventPred::DistanceChanged {
221+
EventPred::FrontierSize {
222222
distance,
223223
nodes: self.queue.len(),
224224
},

algo/tests/test_breadth_first.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ macro_rules! test_bfv_algo_seq {
175175
if let breadth_first::EventPred::Unknown { distance, .. } = event {
176176
*expected_distance_to_quantity.entry(distance).or_insert(0) += 1;
177177
}
178-
if let breadth_first::EventPred::DistanceChanged { nodes, distance } = event
179-
{
178+
if let breadth_first::EventPred::FrontierSize { nodes, distance } = event {
180179
*distance_to_quantity.entry(distance).or_insert(0) += nodes;
181180
}
182181
Continue(())
@@ -200,8 +199,7 @@ macro_rules! test_bfv_algo_seq {
200199
if let breadth_first::EventPred::Unknown { distance, .. } = event {
201200
*expected_distance_to_quantity.entry(distance).or_insert(0) += 1;
202201
}
203-
if let breadth_first::EventPred::DistanceChanged { nodes, distance } = event
204-
{
202+
if let breadth_first::EventPred::FrontierSize { nodes, distance } = event {
205203
*distance_to_quantity.entry(distance).or_insert(0) += nodes;
206204
}
207205
Continue(())
@@ -360,7 +358,7 @@ macro_rules! test_bfv_algo_par {
360358
.entry(distance)
361359
.or_insert(0) += 1;
362360
}
363-
if let breadth_first::EventPred::DistanceChanged { nodes, distance } =
361+
if let breadth_first::EventPred::FrontierSize { nodes, distance } =
364362
event
365363
{
366364
*distance_to_quantity
@@ -405,7 +403,7 @@ macro_rules! test_bfv_algo_par {
405403
.entry(distance)
406404
.or_insert(0) += 1;
407405
}
408-
if let breadth_first::EventPred::DistanceChanged { nodes, distance } =
406+
if let breadth_first::EventPred::FrontierSize { nodes, distance } =
409407
event
410408
{
411409
*distance_to_quantity

0 commit comments

Comments
 (0)