From 352498245f2719860843cc7d9f7503187c42077b Mon Sep 17 00:00:00 2001 From: Karsten Schmidt Date: Sat, 14 Nov 2020 00:03:21 +0000 Subject: [PATCH] refactor(adjacency): update destructuring --- packages/adjacency/src/bfs.ts | 7 ++----- packages/adjacency/src/sparse.ts | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/adjacency/src/bfs.ts b/packages/adjacency/src/bfs.ts index 586b41ce15..99235ef4cc 100644 --- a/packages/adjacency/src/bfs.ts +++ b/packages/adjacency/src/bfs.ts @@ -20,9 +20,7 @@ export class BFS { search(ids: Iterable, cost: CostFn = () => 1) { const queue = new DCons(ids); - const dist = this.dist; - const edges = this.edges; - const marked = this.marked; + const { dist, edges, marked } = this; dist.fill(0xffffffff); for (let id of ids) { dist[id] = 0; @@ -49,8 +47,7 @@ export class BFS { pathTo(id: number) { if (!this.hasPathTo(id)) return; const path: number[] = []; - const dist = this.dist; - const edges = this.edges; + const { dist, edges } = this; let i = id; for (; dist[i] > 0; i = edges[i]) { path.push(i); diff --git a/packages/adjacency/src/sparse.ts b/packages/adjacency/src/sparse.ts index d4e00f2104..3e8e40ef01 100644 --- a/packages/adjacency/src/sparse.ts +++ b/packages/adjacency/src/sparse.ts @@ -47,8 +47,7 @@ export class AdjacencyMatrix extends CSR implements IGraph { } *edges() { - const rows = this.rows; - const cols = this.cols; + const { cols, rows } = this; const directed = !this.undirected; for (let i = 0; i < this.m; i++) { const jj = rows[i + 1];