| seed_prior | R Documentation |
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.
seed_prior(
seeds,
seed_weight = NULL,
seed_url_col = "url",
seed_weight_col = "weight"
)
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. |
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()]).
A data frame with 'url' and 'weight' columns, suitable as the 'prior_df' argument to [pagerank()].
[trustrank()], [topic_feeder_pagerank()], [topic_sensitive_pagerank()], [pagerank()], [align_prior_to_vertices()]
# A trusted-seed prior for TrustRank: run on the FORWARD graph, trust flows
# outward from the seeds.
prior <- seed_prior(c("/", "/hub"))
prior
edges <- data.frame(
from = c("/", "/hub", "/feeder"),
to = c("/hub", "/ai", "/ai")
)
pagerank(edges, prior_df = prior, clean_edge_urls = FALSE)
# 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)
# Graded emphasis via a data frame.
seed_prior(data.frame(url = c("/a", "/b"), weight = c(3, 1)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.