Skip to content

Commit e72c71c

Browse files
committed
Simplified tests
1 parent 6123bc8 commit e72c71c

File tree

3 files changed

+15
-18
lines changed

3 files changed

+15
-18
lines changed

webgraph/src/traits/graph.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ struct this_method_cannot_be_called_use_successors_instead;
5656
/// ascending order, or the successors of a node will be returned in ascending
5757
/// order. The marker traits [`SortedLender`] and [`SortedIterator`] can be used
5858
/// to force these properties.
59+
///
60+
/// The function [`eq`](eq) can be used to check whether two
61+
/// graphs are equal.
5962
#[autoimpl(for<S: trait + ?Sized> &S, &mut S, Rc<S>)]
6063
pub trait SequentialGraph: SequentialLabeling<Label = usize> {}
6164

@@ -146,6 +149,9 @@ pub trait RandomAccessGraph: RandomAccessLabeling<Label = usize> + SequentialGra
146149
/// A labeled sequential graph is a sequential labeling whose labels are pairs
147150
/// `(usize, L)`. The first coordinate is the successor, the second is the
148151
/// label.
152+
///
153+
/// The function [`eq_labeled`](eq_labeled) can be used to check whether two
154+
/// labeled graphs are equal.
149155
#[autoimpl(for<S: trait + ?Sized> &S, &mut S, Rc<S>)]
150156
pub trait LabeledSequentialGraph<L>: SequentialLabeling<Label = (usize, L)> {}
151157

webgraph/src/traits/labels.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ use sux::{traits::Succ, utils::FairChunks};
5656
/// [`par_apply`](SequentialLabeling::par_apply) and
5757
/// [`par_node_apply`](SequentialLabeling::par_node_apply), that make it easy to
5858
/// process in parallel the nodes of the labeling.
59+
///
60+
/// The function [`eq_sorted`](eq_sorted) can be used to check whether two
61+
/// sorted labelings are equal.
5962
#[autoimpl(for<S: trait + ?Sized> &S, &mut S, Rc<S>)]
6063
pub trait SequentialLabeling {
6164
type Label;
@@ -327,6 +330,9 @@ impl<I: ExactSizeIterator> ExactSizeIterator for SortedIter<I> {
327330

328331
/// A [`SequentialLabeling`] providing, additionally, random access to
329332
/// the list of labels associated with a node.
333+
///
334+
/// The function [`check_impl`](check_impl) can be used to check whether the
335+
/// sequential and random-access implementations of a labeling are consistent.
330336
#[autoimpl(for<S: trait + ?Sized> &S, &mut S, Rc<S>)]
331337
pub trait RandomAccessLabeling: SequentialLabeling {
332338
/// The type of the iterator over the labels of a node

webgraph/tests/test_par_bvcomp.rs

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use anyhow::Result;
1212
use dsi_bitstream::prelude::*;
1313
use dsi_progress_logger::prelude::*;
1414
use lender::*;
15+
use log::info;
1516
use webgraph::prelude::*;
1617

1718
#[test]
@@ -72,25 +73,9 @@ fn _test_par_bvcomp(basename: &str) -> Result<()> {
7273
webgraph::graphs::bvgraph::sequential::BvGraphSeq::with_basename(&tmp_basename)
7374
.endianness::<BE>()
7475
.load()?;
75-
let mut iter = comp_graph.iter();
7676

77-
let mut pr = ProgressLogger::default();
78-
pr.display_memory(true)
79-
.item_name("node")
80-
.expected_updates(Some(graph.num_nodes()));
81-
pr.start("Checking that the newly compressed graph is equivalent to the original one...");
82-
83-
let mut iter_nodes = graph.iter();
84-
while let Some((node, succ_iter)) = iter_nodes.next() {
85-
let (new_node, new_succ_iter) = iter.next().unwrap();
86-
assert_eq!(node, new_node);
87-
let succ = succ_iter.collect::<Vec<_>>();
88-
let new_succ = new_succ_iter.collect::<Vec<_>>();
89-
assert_eq!(succ, new_succ, "Node {} differs", node);
90-
pr.light_update();
91-
}
92-
93-
pr.done();
77+
info!("Checking that the newly compressed graph is equivalent to the original one...");
78+
assert!(graph::eq(&graph, &comp_graph));
9479

9580
let offsets_path = tmp_basename.with_extension(OFFSETS_EXTENSION);
9681
let mut offsets_reader =

0 commit comments

Comments
 (0)