Skip to content

Commit cab2d5a

Browse files
committed
Add layout feature
1 parent 83cb291 commit cab2d5a

File tree

75 files changed

+213
-96
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+213
-96
lines changed

.bin/batchFix.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
4+
const isDirectory = dirPath => fs.lstatSync(dirPath).isDirectory();
5+
const listFiles = dirPath => fs.readdirSync(dirPath).filter(fileName => !fileName.startsWith('.'));
6+
const listDirectories = dirPath => listFiles(dirPath).filter(fileName => isDirectory(path.resolve(dirPath, fileName)));
7+
8+
const rootPath = path.resolve(__dirname, '..');
9+
listDirectories(rootPath).forEach(category => {
10+
const categoryPath = path.resolve(rootPath, category);
11+
listDirectories(categoryPath).forEach(algorithm => {
12+
const algorithmPath = path.resolve(categoryPath, algorithm);
13+
listFiles(algorithmPath).filter(file => /\.js$/.test(file)).forEach(file => {
14+
const filePath = path.resolve(algorithmPath, file);
15+
const content = fs.readFileSync(filePath, 'utf8');
16+
17+
const variables = [];
18+
let lineNumber = -1;
19+
let needDelay = false;
20+
const lines = content.split('\n').map((line, i) => {
21+
const match = /^\s*const (\w+) = new \w*Tracer\(/g.exec(line);
22+
if (match) {
23+
variables.push(match[1]);
24+
lineNumber = i;
25+
line = line.replace(/\.delay\(\s*\)/g, () => {
26+
needDelay = true;
27+
return '';
28+
});
29+
}
30+
return line.replace(' } = require(\'algorithm-visualizer\')', ', Layout, VerticalLayout } = require(\'algorithm-visualizer\')');
31+
});
32+
33+
if (~lineNumber) {
34+
const line = `Layout.setRoot(new VerticalLayout([${variables.join(', ')}]))${needDelay ? '.delay()' : ''};`;
35+
lines.splice(lineNumber + 1, 0, line);
36+
const newContent = lines.join('\n');
37+
fs.writeFileSync(filePath, newContent, 'utf8');
38+
} else {
39+
console.error('wtf');
40+
}
41+
});
42+
});
43+
});

Backtracking/Knight's Tour Problem/code.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, Array2DTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, Array2DTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
/*
44
For N>3 the time taken by this algorithm is sufficiently high
@@ -28,7 +28,8 @@ pos[0] = pos[1] = -1;
2828

2929
const boardTracer = new Array2DTracer('Board').set(board);
3030
const posTracer = new Array1DTracer('Knight Position').set(pos);
31-
const logTracer = new LogTracer('Console').delay();
31+
const logTracer = new LogTracer('Console');
32+
Layout.setRoot(new VerticalLayout([boardTracer, posTracer, logTracer])).delay();
3233

3334
function knightTour(x, y, moveNum) {
3435
if (moveNum === N * N) {

Backtracking/N-Queens Problem/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array2DTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array2DTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const N = 4; // just change the value of N and the visuals will reflect the configuration!
44
const board = (function createArray(N) {
@@ -19,6 +19,7 @@ const queens = (function qSetup(N) {
1919
const boardTracer = new Array2DTracer('Board');
2020
const queenTracer = new Array2DTracer('Queen Positions');
2121
const logger = new LogTracer('Progress');
22+
Layout.setRoot(new VerticalLayout([boardTracer, queenTracer, logger]));
2223

2324
boardTracer.set(board);
2425
queenTracer.set(queens);

Branch and Bound/Binary Search Tree/insertion.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
const { Array1DTracer, GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const T = {};
44

55
const elements = [5, 8, 10, 3, 1, 6, 9, 7, 2, 0, 4]; // item to be inserted
66
const graphTracer = new GraphTracer(' BST - Elements marked red indicates the current status of tree ');
77
const elemTracer = new Array1DTracer(' Elements ').set(elements);
88
const logger = new LogTracer(' Log ');
9+
Layout.setRoot(new VerticalLayout([graphTracer, elemTracer, logger]));
910
graphTracer.log(logger).delay();
1011

1112
function bstInsert(root, element, parent) { // root = current node , parent = previous node

Branch and Bound/Binary Search Tree/search.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
44
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -31,6 +31,7 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
3131
const key = new Randomize.Integer(0, G.length - 1).create(); // item to be searched
3232
const tracer = new GraphTracer(' Binary Search Tree ').set(G).layoutTree(5);
3333
const logger = new LogTracer(' Log ');
34+
Layout.setRoot(new VerticalLayout([tracer, logger]));
3435
tracer.log(logger).delay();
3536

3637
function bst(item, node, parent) { // node = current node , parent = previous node

Branch and Bound/Binary Search/iterative.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15, new Randomize.Integer(0, 50)).sorted().create();
78
tracer.set(D).delay();
89

Branch and Bound/Binary Search/recursive.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15, new Randomize.Integer(0, 50)).sorted().create();
78
tracer.set(D).delay();
89

Branch and Bound/Depth-Limited Search/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer();
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
tracer.log(logger);
67
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
78
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],

Branch and Bound/Topological Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer();
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
tracer.log(logger);
67
// G[i][j] indicates whether the path from the i-th node to the j-th node exists or not. NOTE: The graph must be Directed-Acyclic
78
const G = [

Brute Force/Binary Tree Traversal/inOrder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
44
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -30,7 +30,8 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
3030

3131
const treeTracer = new GraphTracer(' Traversal In-order ').set(G).layoutTree(5);
3232
const arrayTracer = new Array1DTracer(' Print In-order ').set(new Array(T.length).fill('-'));
33-
const logger = new LogTracer(' Log ').delay();
33+
const logger = new LogTracer(' Log ');
34+
Layout.setRoot(new VerticalLayout([treeTracer, arrayTracer, logger])).delay();
3435

3536
let index = 0;
3637

Brute Force/Binary Tree Traversal/postOrder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
44
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -30,7 +30,8 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
3030

3131
const treeTracer = new GraphTracer(' Traversal Post-order ').set(G).layoutTree(5);
3232
const arrayTracer = new Array1DTracer(' Print Post-order ').set(new Array(T.length).fill('-'));
33-
const logger = new LogTracer(' Log ').delay();
33+
const logger = new LogTracer(' Log ');
34+
Layout.setRoot(new VerticalLayout([treeTracer, arrayTracer, logger])).delay();
3435

3536
let index = 0;
3637

Brute Force/Binary Tree Traversal/preOrder.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
44
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -30,7 +30,8 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
3030

3131
const treeTracer = new GraphTracer(' Traversal Pre-order ').set(G).layoutTree(5);
3232
const arrayTracer = new Array1DTracer(' Print Pre-order ').set(new Array(T.length).fill('-'));
33-
const logger = new LogTracer(' Log ').delay();
33+
const logger = new LogTracer(' Log ');
34+
Layout.setRoot(new VerticalLayout([treeTracer, arrayTracer, logger])).delay();
3435

3536
let index = 0;
3637

Brute Force/Bipartiteness Test/code.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().directed(false);
44
const logger = new LogTracer();
@@ -13,7 +13,8 @@ const G = [
1313
];
1414
tracer.set(G);
1515

16-
const colorsTracer = new Array1DTracer('Colors').delay();
16+
const colorsTracer = new Array1DTracer('Colors');
17+
Layout.setRoot(new VerticalLayout([tracer, logger, colorsTracer])).delay();
1718

1819
function BFSCheckBipartiteness(s) {
1920
const Q = [];

Brute Force/Breadth-First Search/shortestPath.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().directed(false).weighted();
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
tracer.log(logger);
67
const G = new Randomize.Graph(5, 1).directed(false).weighted().create();
78
tracer.set(G).delay();

Brute Force/Breadth-First Search/tree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().log(new LogTracer());
4+
Layout.setRoot(new VerticalLayout([tracer]));
45
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
56
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
67
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],

Brute Force/Bridge Finding/efficient.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const graphTracer = new GraphTracer().directed(false);
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([graphTracer, logger]));
56
const G = [
67
[0, 1, 0, 0, 1, 0],
78
[1, 0, 0, 0, 1, 0],

Brute Force/Bridge Finding/naive.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().directed(false);
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
const G = [
67
[0, 1, 0, 0, 0, 0],
78
[1, 0, 0, 1, 1, 0],

Brute Force/Bubble Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15).create();
78
tracer.set(D).delay();
89

Brute Force/Comb Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15).create();
78
tracer.set(D).delay();
89

Brute Force/Cycle Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15).create();
78
tracer.set(D).delay();
89

Brute Force/Depth-First Search/graph.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const graphTracer = new GraphTracer().directed(false);
44
const visitedTracer = new Array1DTracer('visited');
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([graphTracer, visitedTracer, logger]));
67
graphTracer.log(logger);
78
const G = new Randomize.Graph(8, .3).directed(false).create();
89
graphTracer.set(G).delay();

Brute Force/Depth-First Search/shortestPath.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().directed(false).weighted();
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
tracer.log(logger);
67
const G = new Randomize.Graph(5, 1).directed(false).weighted().create();
78
tracer.set(G).delay();

Brute Force/Depth-First Search/tree.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().log(new LogTracer());
4+
Layout.setRoot(new VerticalLayout([tracer]));
45
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
56
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
67
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],

Brute Force/Depth-First Search/weightedGraph.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
const { GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new GraphTracer().directed(false).weighted();
44
const logger = new LogTracer();
5+
Layout.setRoot(new VerticalLayout([tracer, logger]));
56
tracer.log(logger);
67
const G = new Randomize.Graph(5, 1).directed(false).weighted().create();
78
tracer.set(G).delay();

Brute Force/Flood Fill/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
const { Array2DTracer } = require('algorithm-visualizer');
1+
const { Array2DTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const tracer = new Array2DTracer();
4+
Layout.setRoot(new VerticalLayout([tracer]));
45
const G = [
56
['#', '#', '#', '#', '#', '#', '#', '#', '#'],
67
['#', '-', '-', '-', '#', '-', '-', '-', '#'],

Brute Force/Heapsort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(10).create();
78
tracer.set(D).delay();
89

Brute Force/Insertion Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(15).create();
78
tracer.set(D).delay();
89

Brute Force/Lowest Common Ancestor/code.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { GraphTracer, LogTracer } = require('algorithm-visualizer');
1+
const { GraphTracer, LogTracer, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
44
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
@@ -29,7 +29,8 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
2929
];
3030

3131
const treeTracer = new GraphTracer(' Traversal Pre-order ').set(G).layoutTree(5);
32-
const logger = new LogTracer(' Log ').delay();
32+
const logger = new LogTracer(' Log ');
33+
Layout.setRoot(new VerticalLayout([treeTracer, logger])).delay();
3334

3435
function lcaBT(parent, root, a, b) {
3536
logger.println(`Beginning new Iteration of lcaBT () with parent: ${parent}, current root: ${root}`);

Brute Force/PageRank/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { Array1DTracer, Array2DTracer, GraphTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, Array2DTracer, GraphTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
function filledArray(length, value) {
44
return Array(...Array(length)).map(Number.prototype.valueOf, value);
@@ -14,6 +14,7 @@ const oecTracer = new Array1DTracer('Outgoing Edge Counts');
1414
const inTracer = new Array2DTracer('Incoming Nodes');
1515

1616
const logger = new LogTracer();
17+
Layout.setRoot(new VerticalLayout([graphTracer, rankTracer, oecTracer, inTracer, logger]));
1718

1819
graphTracer.set(G);
1920
oecTracer.set(outgoingEdgeCounts);

Brute Force/Pancake Sort/code.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const { Array1DTracer, ChartTracer, LogTracer, Randomize } = require('algorithm-visualizer');
1+
const { Array1DTracer, ChartTracer, LogTracer, Randomize, Layout, VerticalLayout } = require('algorithm-visualizer');
22

33
const chart = new ChartTracer();
44
const tracer = new Array1DTracer().chart(chart);
55
const logger = new LogTracer();
6+
Layout.setRoot(new VerticalLayout([chart, tracer, logger]));
67
const D = new Randomize.Array1D(10).create();
78
tracer.set(D).delay();
89

0 commit comments

Comments
 (0)