Skip to content

Commit 5d28053

Browse files
rustworkx-core: fix docs build warnings (#1333)
* core/steiner_tree: fix rustdoc warnings * core/generators/dorogovtsev_goltsev_mendes: fix rustdoc warnings * core/centrality: fix rustdoc warnings * workflows/main: error on warnings during rustworkx-core doc build * Pin Rust to 1.82 for clippy * Revert: Pin Rust to 1.82 to work around #1331 This reverts commit 1977f66. --------- Co-authored-by: Ivan Carvalho <[email protected]>
1 parent b66662f commit 5d28053

File tree

4 files changed

+44
-30
lines changed

4 files changed

+44
-30
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ jobs:
4646
run: pushd rustworkx-core && cargo test && popd
4747
- name: rustworkx-core Docs
4848
run: pushd rustworkx-core && cargo doc && popd
49+
env:
50+
RUSTDOCFLAGS: '-D warnings'
4951
- uses: actions/upload-artifact@v4
5052
with:
5153
name: rustworkx_core_docs

rustworkx-core/src/centrality.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,18 +1073,21 @@ mod test_katz_centrality {
10731073
/// In the case of a graphs with more than one connected component there is
10741074
/// an alternative improved formula that calculates the closeness centrality
10751075
/// as "a ratio of the fraction of actors in the group who are reachable, to
1076-
/// the average distance" [^WF]. You can enable this by setting `wf_improved` to `true`.
1076+
/// the average distance".[^WF]
1077+
/// You can enable this by setting `wf_improved` to `true`.
10771078
///
1078-
/// [^WF] Wasserman, S., & Faust, K. (1994). Social Network Analysis:
1079+
/// [^WF]: Wasserman, S., & Faust, K. (1994). Social Network Analysis:
10791080
/// Methods and Applications (Structural Analysis in the Social Sciences).
1080-
/// Cambridge: Cambridge University Press. doi:10.1017/CBO9780511815478
1081+
/// Cambridge: Cambridge University Press.
1082+
/// <https://doi.org/10.1017/CBO9780511815478>
10811083
///
1082-
/// Arguments:
1084+
/// # Arguments
10831085
///
10841086
/// * `graph` - The graph object to run the algorithm on
10851087
/// * `wf_improved` - If `true`, scale by the fraction of nodes reachable.
10861088
///
10871089
/// # Example
1090+
///
10881091
/// ```rust
10891092
/// use rustworkx_core::petgraph;
10901093
/// use rustworkx_core::centrality::closeness_centrality;

rustworkx-core/src/generators/dorogovtsev_goltsev_mendes_graph.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,19 @@ use super::InvalidInputError;
1616

1717
/// Generate a Dorogovtsev-Goltsev-Mendes graph
1818
///
19-
/// Generate a graph following the recursive procedure in [1].
19+
/// Generate a graph following the recursive procedure by Dorogovtsev, Goltsev,
20+
/// and Mendes[^DGM2002].
2021
/// Starting from the two-node, one-edge graph, iterating `n` times generates
21-
/// a graph with `(3**n + 3) // 2` nodes and `3**n` edges.
22+
/// a graph with `(3^n + 3) // 2` nodes and `3^n` edges.
2223
///
24+
/// # Arguments
2325
///
24-
/// Arguments:
25-
///
26-
/// * `n` - The number of iterations to perform. n=0 returns the two-node, one-edge graph.
26+
/// * `n` - The number of iterations to perform. `n = 0` returns the two-node, one-edge graph.
2727
/// * `default_node_weight` - A callable that will return the weight to use for newly created nodes.
2828
/// * `default_edge_weight` - A callable that will return the weight object to use for newly created edges.
2929
///
3030
/// # Example
31+
///
3132
/// ```rust
3233
/// use rustworkx_core::petgraph;
3334
/// use rustworkx_core::generators::dorogovtsev_goltsev_mendes_graph;
@@ -43,10 +44,10 @@ use super::InvalidInputError;
4344
/// );
4445
/// ```
4546
///
46-
/// .. [1] S. N. Dorogovtsev, A. V. Goltsev and J. F. F. Mendes
47+
/// [^DGM2002]: S. N. Dorogovtsev, A. V. Goltsev and J. F. F. Mendes
4748
/// “Pseudofractal scale-free web”
48-
/// Physical Review E 65, 066122, 2002
49-
/// https://arxiv.org/abs/cond-mat/0112143
49+
/// Physical Review E 65, 066122 (2002)
50+
/// <https://arxiv.org/abs/cond-mat/0112143>
5051
///
5152
pub fn dorogovtsev_goltsev_mendes_graph<G, T, F, H, M>(
5253
n: usize,

rustworkx-core/src/steiner_tree.rs

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ where
437437
Ok(out_edges)
438438
}
439439

440+
/// Solution to a minimum Steiner tree problem.
441+
///
442+
/// This `struct` is created by the [steiner_tree] function.
440443
pub struct SteinerTreeResult {
441444
pub used_node_indices: HashSet<usize>,
442445
pub used_edge_endpoints: HashSet<(usize, usize)>,
@@ -454,21 +457,25 @@ pub struct SteinerTreeResult {
454457
/// complete graph in which each edge is weighted by the shortest path distance
455458
/// between nodes in ``graph``.
456459
///
457-
/// This algorithm [1]_ produces a tree whose weight is within a
458-
/// :math:`(2 - (2 / t))` factor of the weight of the optimal Steiner tree
459-
/// where :math:`t` is the number of terminal nodes. The algorithm implemented
460-
/// here is due to [2]_ . It avoids computing all pairs shortest paths but rather
461-
/// reduces the problem to a single source shortest path and a minimum spanning tree
462-
/// problem.
460+
/// This algorithm by Kou, Markowsky, and Berman[^KouMarkowskyBerman1981]
461+
/// produces a tree whose weight is within a `(2 - (2 / t))` factor of
462+
/// the weight of the optimal Steiner tree where `t` is the number of
463+
/// terminal nodes.
464+
/// The algorithm implemented here is due to Mehlhorn[^Mehlhorn1987]. It avoids
465+
/// computing all pairs shortest paths but rather reduces the problem to a
466+
/// single source shortest path and a minimum spanning tree problem.
463467
///
464-
/// Arguments:
465-
/// `graph`: The input graph to compute the steiner tree of
466-
/// `terminal_nodes`: The terminal nodes of the steiner tree
467-
/// `weight_fn`: A callable weight function that will be passed an edge reference
468-
/// for each edge in the graph and it is expected to return a `Result<f64>`
469-
/// which if it doesn't error represents the weight of that edge.
468+
/// # Arguments
469+
///
470+
/// - `graph` - The input graph to compute the Steiner tree of
471+
/// - `terminal_nodes` - The terminal nodes of the Steiner tree
472+
/// - `weight_fn` - A callable weight function that will be passed an edge reference
473+
/// for each edge in the graph and it is expected to return a [`Result<f64>`]
474+
/// which if it doesn't error represents the weight of that edge.
475+
///
476+
/// # Returns
470477
///
471-
/// Returns a custom struct that contains a set of nodes and edges and `None`
478+
/// A custom struct that contains a set of nodes and edges and `None`
472479
/// if the graph is disconnected relative to the terminal nodes.
473480
///
474481
/// # Example
@@ -509,13 +516,14 @@ pub struct SteinerTreeResult {
509516
/// let tree = steiner_tree(&input_graph, &terminal_nodes, weight_fn).unwrap().unwrap();
510517
/// ```
511518
///
512-
/// .. [1] Kou, Markowsky & Berman,
519+
/// [^KouMarkowskyBerman1981]: Kou, Markowsky & Berman,
513520
/// "A fast algorithm for Steiner trees"
514-
/// Acta Informatica 15, 141–145 (1981).
515-
/// https://link.springer.com/article/10.1007/BF00288961
516-
/// .. [2] Kurt Mehlhorn,
521+
/// Acta Informatica 15, 141–145 (1981)
522+
/// <https://link.springer.com/article/10.1007/BF00288961>
523+
/// [^Mehlhorn1987]: Kurt Mehlhorn,
517524
/// "A faster approximation algorithm for the Steiner problem in graphs"
518-
/// https://doi.org/10.1016/0020-0190(88)90066-X
525+
/// Information Processing Letters 27(3), 125-128 (1987)
526+
/// <https://doi.org/10.1016/0020-0190(88)90066-X>
519527
pub fn steiner_tree<G, F, E>(
520528
graph: G,
521529
terminal_nodes: &[G::NodeId],

0 commit comments

Comments
 (0)