View source: R/validate_edge_weights.R
| validate_edge_weights | R Documentation |
Inspect a weighted edge list before it reaches the PageRank solver. The report identifies negative and non-finite weights, degenerate sources whose outgoing weights are all zero, and (optionally) source totals that do not match an expected probability total.
validate_edge_weights(
edge_list_df,
weight_col = "weight",
from_col = "from",
expected_total = NULL,
tolerance = sqrt(.Machine$double.eps),
action = c("error", "warning", "none")
)
edge_list_df |
A data frame containing source and weight columns. |
weight_col |
Name of the numeric edge-weight column. |
from_col |
Name of the source-node column used to define outgoing choice sets. |
expected_total |
Optional finite, non-negative total expected for each source. Use '1' to validate an already-normalized transition-probability column. 'NULL' (default) reports totals without enforcing a target. |
tolerance |
Non-negative numeric tolerance for 'expected_total'. |
action |
How validation failures are handled: '"error"' (default), '"warning"', or '"none"'. The report is returned in every mode. |
A data frame with one row per source and columns describing edge count, weight total, invalid-value counts, all-zero status, optional total agreement, and overall validity.
edges <- data.frame(
from = c("A", "A", "B"),
to = c("B", "C", "C"),
probability = c(0.25, 0.75, 1)
)
validate_edge_weights(
edges,
weight_col = "probability",
expected_total = 1
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.