pub(super) fn link_order(
    graph: &PackageGraph,
    ids: &[&PackageId],
    query_direction: DependencyDirection,
    iter_direction: DependencyDirection,
    msg: &str,
) {
    let package_set = graph
        .query_directed(ids.iter().copied(), query_direction)
        .unwrap()
        .resolve();
    // If the query and iter directions are the same, the set of initial IDs may be expanded
    // in case of cycles. If they are the opposite, the set of initial IDs will be different as
    // well. Compute the root IDs from the graph in that case.
    let has_cycles = graph.cycles().all_cycles().count() > 0;
    let initials = if has_cycles || query_direction != iter_direction {
        package_set.root_ids(iter_direction).collect()
    } else {
        ids.to_vec()
    };
    let links = package_set.links(iter_direction);
    assert_link_order(
        links,
        initials,
        iter_direction,
        &format!("{}: link order", msg),
    );
}
Test that all results of an into_iter_links query follow link order.
guppy/tests/graph-tests/proptest_helpers.rs