Skip to contents

Build a teleport prior (a `prior_df`) concentrated on a set of **seed** pages. A seed prior is the teleportation vector that biases the random surfer toward the seeds instead of jumping uniformly, and it is the single ingredient shared by the seed-biased members of the PageRank family: [trustrank()] (trusted seeds) and [topic_feeder_pagerank()] (a target cluster) both build one and hand it to [pagerank()].

`seed_prior()` is **orientation-agnostic**: it does nothing but turn a seed set into a `url`/`weight` prior. Whether teleport mass then flows *outward* from the seeds (trust) or is accumulated by pages that *point into* the seeds (feeders) is a property of the **graph**, chosen by the caller — not of this builder. [trustrank()] runs the prior on the forward graph; [topic_feeder_pagerank()] runs the identical prior on the reversed graph (`pagerank(reverse = TRUE)`). That is precisely why one builder serves both: the direction lives in the wrapper, not in the prior.

For the multi-topic case ([topic_sensitive_pagerank()]) the prior is built internally per topic from a named list; `seed_prior()` covers the single-seed-set case that the two convenience wrappers share.

Usage

seed_prior(
  seeds,
  seed_weight = NULL,
  seed_url_col = "url",
  seed_weight_col = "weight"
)

Arguments

seeds

The seed set. Either a character vector of seed URLs (each gets equal weight unless `seed_weight` is given), or a data frame with a URL column and a numeric weight column (see `seed_url_col` / `seed_weight_col`) for unequal emphasis.

seed_weight

Optional numeric weight for a character-vector `seeds`: either one value per seed or a single value recycled to all seeds. Ignored when `seeds` is a data frame. Default `NULL` (every seed weight `1`, i.e. a uniform distribution over the seed set).

seed_url_col, seed_weight_col

Column names used when `seeds` is a data frame. Defaults `"url"` / `"weight"`. Ignored for a character vector.

Value

A data frame with `url` and `weight` columns, suitable as the `prior_df` argument to [pagerank()].

Details

Seed weights are an **additive teleport budget**: when two seed URLs fold onto the same vertex (redirect / canonical variants) their weights sum, exactly as the [pagerank()] / [align_prior_to_vertices()] prior contract specifies. Equal weights give a uniform distribution over the seed set; unequal weights express graded emphasis (graded trust for [trustrank()], graded cluster importance for [topic_feeder_pagerank()]).

See also

[trustrank()], [topic_feeder_pagerank()], [topic_sensitive_pagerank()], [pagerank()], [align_prior_to_vertices()]

Examples

# A trusted-seed prior for TrustRank: run on the FORWARD graph, trust flows
# outward from the seeds.
prior <- seed_prior(c("/", "/hub"))
prior
#>    url weight
#> 1    /      1
#> 2 /hub      1

edges <- data.frame(
  from = c("/", "/hub", "/feeder"),
  to = c("/hub", "/ai", "/ai")
)
pagerank(edges, prior_df = prior, clean_edge_urls = FALSE)
#> TIPR prior aligned: 2/4 real vertices carry authority; transform='none', alpha=0 (uniform mass ~0.0%). 0 prior URL(s) (sum weight 0) did not fold onto any vertex and were dropped.
#>   node_name  pagerank prior_weight
#> 1         / 0.2261164          0.5
#> 2       /ai 0.3555681          0.0
#> 3   /feeder 0.0000000          0.0
#> 4      /hub 0.4183154          0.5

# The SAME builder makes a cluster prior for feeder PageRank; the only
# difference is the graph orientation you run it on (reverse = TRUE).
cluster <- seed_prior("/ai")
pagerank(edges, prior_df = cluster, reverse = TRUE, clean_edge_urls = FALSE)
#> TIPR prior aligned: 1/4 real vertices carry authority; transform='none', alpha=0 (uniform mass ~0.0%). 0 prior URL(s) (sum weight 0) did not fold onto any vertex and were dropped.
#>   node_name  pagerank prior_weight
#> 1         / 0.1633691            0
#> 2       /ai 0.4522329            1
#> 3   /feeder 0.1921990            0
#> 4      /hub 0.1921990            0

# Graded emphasis via a data frame.
seed_prior(data.frame(url = c("/a", "/b"), weight = c(3, 1)))
#>   url weight
#> 1  /a      3
#> 2  /b      1