Skip to content

Commit

Permalink
refactor(adjacency): update destructuring
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Nov 14, 2020
1 parent 7af7a92 commit 3524982
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
7 changes: 2 additions & 5 deletions packages/adjacency/src/bfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ export class BFS {

search(ids: Iterable<number>, cost: CostFn = () => 1) {
const queue = new DCons<number>(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;
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions packages/adjacency/src/sparse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down

0 comments on commit 3524982

Please sign in to comment.