From 441d6df25530688fa51dec1b75cd6da536c6c6bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Thu, 7 Mar 2019 23:04:07 -0700 Subject: [PATCH] Move default pagerank settings to pagerankGraph (#1112) This commit moves the default Pagerank options out of `analysis/pagerank` and to `core/pagerankGraph`. This reflects the gradual migration of core pagerank logic into `pagerankGraph`. Test plan: `yarn test` should suffice. It's a trivial change. --- src/analysis/pagerank.js | 11 ++++++++--- src/core/pagerankGraph.js | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/analysis/pagerank.js b/src/analysis/pagerank.js index 20a79f8..7aec9dc 100644 --- a/src/analysis/pagerank.js +++ b/src/analysis/pagerank.js @@ -1,6 +1,11 @@ // @flow import {type Edge, Graph, NodeAddress, type NodeAddressT} from "../core/graph"; +import { + DEFAULT_MAX_ITERATIONS, + DEFAULT_CONVERGENCE_THRESHOLD, + DEFAULT_SYNTHETIC_LOOP_WEIGHT, +} from "../core/pagerankGraph"; import { distributionToNodeDistribution, createConnections, @@ -35,9 +40,9 @@ export type EdgeEvaluator = (Edge) => EdgeWeight; function defaultOptions(): PagerankOptions { return { verbose: false, - selfLoopWeight: 1e-3, - convergenceThreshold: 1e-7, - maxIterations: 255, + selfLoopWeight: DEFAULT_SYNTHETIC_LOOP_WEIGHT, + convergenceThreshold: DEFAULT_CONVERGENCE_THRESHOLD, + maxIterations: DEFAULT_MAX_ITERATIONS, totalScore: 1000, totalScoreNodePrefix: NodeAddress.empty, }; diff --git a/src/core/pagerankGraph.js b/src/core/pagerankGraph.js index 8bf2f8a..3b9d80f 100644 --- a/src/core/pagerankGraph.js +++ b/src/core/pagerankGraph.js @@ -70,6 +70,8 @@ export type PagerankConvergenceReport = {| |}; export const DEFAULT_SYNTHETIC_LOOP_WEIGHT = 1e-3; +export const DEFAULT_MAX_ITERATIONS = 255; +export const DEFAULT_CONVERGENCE_THRESHOLD = 1e-7; const COMPAT_INFO = {type: "sourcecred/pagerankGraph", version: "0.1.0"};