From fed58aee7b14e9d0d0e183da7cca8bf0e358cba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Mon, 9 Jul 2018 14:21:37 -0700 Subject: [PATCH] Rename PagerankResult to NodeDistribution (#504) Test plan: travis --- src/app/credExplorer/App.js | 4 ++-- src/app/credExplorer/PagerankTable.js | 10 +++++----- src/core/attribution/graphToMarkovChain.js | 6 +++--- src/core/attribution/graphToMarkovChain.test.js | 6 +++--- src/core/attribution/pagerank.js | 10 +++++----- src/core/attribution/pagerankNodeDecomposition.js | 4 ++-- src/core/attribution/pagerankNodeDecomposition.test.js | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/app/credExplorer/App.js b/src/app/credExplorer/App.js index 53c43d7..e9c81b0 100644 --- a/src/app/credExplorer/App.js +++ b/src/app/credExplorer/App.js @@ -7,7 +7,7 @@ import LocalStore from "./LocalStore"; import {createPluginAdapter as createGithubAdapter} from "../../plugins/github/pluginAdapter"; import {createPluginAdapter as createGitAdapter} from "../../plugins/git/pluginAdapter"; import {Graph} from "../../core/graph"; -import {pagerank, type PagerankResult} from "../../core/attribution/pagerank"; +import {pagerank, type NodeDistribution} from "../../core/attribution/pagerank"; import {PagerankTable} from "./PagerankTable"; import type {PluginAdapter} from "../pluginAdapter"; import {type EdgeEvaluator} from "../../core/attribution/pagerank"; @@ -24,7 +24,7 @@ type State = { +nodeCount: number, +edgeCount: number, |}, - +pagerankResult: ?PagerankResult, + +pagerankResult: ?NodeDistribution, |}, edgeEvaluator: ?EdgeEvaluator, }; diff --git a/src/app/credExplorer/PagerankTable.js b/src/app/credExplorer/PagerankTable.js index 2434ba2..8968f67 100644 --- a/src/app/credExplorer/PagerankTable.js +++ b/src/app/credExplorer/PagerankTable.js @@ -13,13 +13,13 @@ import { EdgeAddress, type EdgeAddressT, } from "../../core/graph"; -import type {PagerankResult} from "../../core/attribution/pagerank"; +import type {NodeDistribution} from "../../core/attribution/pagerank"; import type {PluginAdapter} from "../pluginAdapter"; const MAX_TABLE_ENTRIES = 100; type Props = { - pagerankResult: ?PagerankResult, + pagerankResult: ?NodeDistribution, graph: ?Graph, adapters: ?$ReadOnlyArray, }; @@ -198,7 +198,7 @@ type RTProps = {| // Present if this RT shows a neighbor (not a top-level node) +edge: ?Edge, +graph: Graph, - +pagerankResult: PagerankResult, + +pagerankResult: NodeDistribution, +depth: number, +adapters: $ReadOnlyArray, |}; @@ -281,7 +281,7 @@ class RecursiveTable extends React.PureComponent { type NodesTablesProps = {| +addresses: $ReadOnlyArray, +graph: Graph, - +pagerankResult: PagerankResult, + +pagerankResult: NodeDistribution, +depth: number, +adapters: $ReadOnlyArray, |}; @@ -318,7 +318,7 @@ class NodesTables extends React.PureComponent { type NeighborsTablesProps = {| +neighbors: $ReadOnlyArray, +graph: Graph, - +pagerankResult: PagerankResult, + +pagerankResult: NodeDistribution, +depth: number, +adapters: $ReadOnlyArray, |}; diff --git a/src/core/attribution/graphToMarkovChain.js b/src/core/attribution/graphToMarkovChain.js index 1588a6b..733ed73 100644 --- a/src/core/attribution/graphToMarkovChain.js +++ b/src/core/attribution/graphToMarkovChain.js @@ -33,7 +33,7 @@ export function contributorSource( } } -export type PagerankResult = Map; +export type NodeDistribution = Map; export type NodeToContributions = Map< NodeAddressT, @@ -251,10 +251,10 @@ export function normalize( return normalizeNeighbors(permute(old, old.nodeOrder.slice().sort())); } -export function distributionToPagerankResult( +export function distributionToNodeDistribution( nodeOrder: $ReadOnlyArray, pi: Distribution -): PagerankResult { +): NodeDistribution { const result = new Map(); nodeOrder.forEach((node, i) => { const probability = pi[i]; diff --git a/src/core/attribution/graphToMarkovChain.test.js b/src/core/attribution/graphToMarkovChain.test.js index ea19047..59f122f 100644 --- a/src/core/attribution/graphToMarkovChain.test.js +++ b/src/core/attribution/graphToMarkovChain.test.js @@ -4,7 +4,7 @@ import sortBy from "lodash.sortby"; import {EdgeAddress, Graph, NodeAddress} from "../graph"; import { - distributionToPagerankResult, + distributionToNodeDistribution, createContributions, createOrderedSparseMarkovChain, normalize, @@ -278,12 +278,12 @@ describe("core/attribution/graphToMarkovChain", () => { }); }); - describe("distributionToPagerankResult", () => { + describe("distributionToNodeDistribution", () => { it("works", () => { const pi = new Float64Array([0.25, 0.75]); const n1 = NodeAddress.fromParts(["foo"]); const n2 = NodeAddress.fromParts(["bar"]); - expect(distributionToPagerankResult([n1, n2], pi)).toEqual( + expect(distributionToNodeDistribution([n1, n2], pi)).toEqual( new Map().set(n1, 0.25).set(n2, 0.75) ); }); diff --git a/src/core/attribution/pagerank.js b/src/core/attribution/pagerank.js index 973a15b..b86c1e5 100644 --- a/src/core/attribution/pagerank.js +++ b/src/core/attribution/pagerank.js @@ -2,8 +2,8 @@ import {type Edge, Graph} from "../graph"; import { - type PagerankResult, - distributionToPagerankResult, + type NodeDistribution, + distributionToNodeDistribution, createContributions, createOrderedSparseMarkovChain, type EdgeWeight, @@ -11,7 +11,7 @@ import { import {findStationaryDistribution} from "./markovChain"; -export type {PagerankResult} from "./graphToMarkovChain"; +export type {NodeDistribution} from "./graphToMarkovChain"; export type PagerankOptions = {| +selfLoopWeight?: number, +verbose?: boolean, @@ -35,7 +35,7 @@ export function pagerank( graph: Graph, edgeWeight: EdgeEvaluator, options?: PagerankOptions -): PagerankResult { +): NodeDistribution { const fullOptions = { ...defaultOptions(), ...(options || {}), @@ -51,5 +51,5 @@ export function pagerank( convergenceThreshold: fullOptions.convergenceThreshold, maxIterations: fullOptions.maxIterations, }); - return distributionToPagerankResult(osmc.nodeOrder, distribution); + return distributionToNodeDistribution(osmc.nodeOrder, distribution); } diff --git a/src/core/attribution/pagerankNodeDecomposition.js b/src/core/attribution/pagerankNodeDecomposition.js index 1e73863..5722fc6 100644 --- a/src/core/attribution/pagerankNodeDecomposition.js +++ b/src/core/attribution/pagerankNodeDecomposition.js @@ -8,7 +8,7 @@ import { type NodeToContributions, contributorSource, } from "./graphToMarkovChain"; -import type {PagerankResult} from "./pagerank"; +import type {NodeDistribution} from "./pagerank"; import * as MapUtil from "../../util/map"; export type ScoredContribution = {| @@ -29,7 +29,7 @@ export type PagerankNodeDecomposition = Map< >; export function decompose( - pr: PagerankResult, + pr: NodeDistribution, contributions: NodeToContributions ): PagerankNodeDecomposition { return MapUtil.mapValues(contributions, (target, contributions) => { diff --git a/src/core/attribution/pagerankNodeDecomposition.test.js b/src/core/attribution/pagerankNodeDecomposition.test.js index df3abda..1bdbb47 100644 --- a/src/core/attribution/pagerankNodeDecomposition.test.js +++ b/src/core/attribution/pagerankNodeDecomposition.test.js @@ -2,7 +2,7 @@ import {EdgeAddress, Graph, NodeAddress, edgeToStrings} from "../graph"; import { - distributionToPagerankResult, + distributionToNodeDistribution, createContributions, createOrderedSparseMarkovChain, } from "./graphToMarkovChain"; @@ -134,7 +134,7 @@ describe("core/attribution/contributions", () => { convergenceThreshold: 1e-6, maxIterations: 255, }); - const pr = distributionToPagerankResult(osmc.nodeOrder, pi); + const pr = distributionToNodeDistribution(osmc.nodeOrder, pi); const result = decompose(pr, contributions); expect(formatDecomposition(result)).toMatchSnapshot(); validateDecomposition(result); @@ -150,7 +150,7 @@ describe("core/attribution/contributions", () => { convergenceThreshold: 1e-6, maxIterations: 255, }); - const pr = distributionToPagerankResult(osmc.nodeOrder, pi); + const pr = distributionToNodeDistribution(osmc.nodeOrder, pi); const result = decompose(pr, contributions); validateDecomposition(result); });