Documentation
¶
Overview ¶
Implemets Google famous and first PageRank algorithm https://en.wikipedia.org/wiki/PageRank
Index ¶
- type Config
- type IncomingScoreMessage
- type Ranker
- func (c *Ranker) AddEdge(src, dst string) error
- func (c *Ranker) AddVertex(id string)
- func (c *Ranker) Close() error
- func (c *Ranker) Executor() *bsp.Executor[float64, any]
- func (c *Ranker) Graph() *bsp.Graph[float64, any]
- func (c *Ranker) Scores(visitFn func(id string, score float64) error) error
- func (c *Ranker) SetExecutorFactory(factory bsp.ExecutorFactory[float64, any])
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // DampingFactor is the probability that a random surfer will click on // one of the outgoing links on the page they are currently visiting // instead of visiting (teleporting to) a random page in the graph. // // If not specified, a default value of 0.85 will be used instead. DampingFactor float64 // At each step of the iterative PageRank algorithm, an accumulator // tracks the sum of absolute differences (SAD) of the PageRank // scores for each vertex in the graph. // // The algorithm will keep executing until the aggregated SAD for all // vertices becomes less than MinSADForConvergence. // // If not specified, a default value of 0.001 will be used instead. MinSADForConvergence float64 // The number of workers to spin up for computing PageRank scores. If // not specified, a default value of 1 will be used instead. ComputeWorkers int }
Config encapsulates the required parameters for creating a new PageRank ranker instance.
type IncomingScoreMessage ¶
type IncomingScoreMessage struct {
Score float64
}
IncomingScoreMessage is used for distributing PageRank scores to neighbors.
func (IncomingScoreMessage) Type ¶
func (pr IncomingScoreMessage) Type() string
type Ranker ¶
type Ranker struct {
// contains filtered or unexported fields
}
Ranker executes the iterative version of the PageRank algorithm on a graph until the desired level of convergence is reached.
func (*Ranker) AddEdge ¶
AddEdge inserts a directed edge from src to dst. If both src and dst refer to the same vertex then this is a no-op.
func (*Ranker) Executor ¶
Executor creates and return a bspgraph.Executor for running the PageRank algorithm once the graph layout has been properly set up.
func (*Ranker) SetExecutorFactory ¶
func (c *Ranker) SetExecutorFactory(factory bsp.ExecutorFactory[float64, any])
SetExecutorFactory configures the ranker to use the a custom executor factory when the Executor method is invoked.