Skip to content

Commit

Permalink
Indentation and jsdoc fixes driven by jscs.
Browse files Browse the repository at this point in the history
  • Loading branch information
anaran committed Jun 9, 2014
1 parent 16b1470 commit 713c6f6
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 65 deletions.
6 changes: 3 additions & 3 deletions algorithms/string/knuth_morris_pratt.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
*
* Asymptotic Complexity: O(text.length)
*
* @param {Array} of Numbers, Strings or Characters
* @param {Array} text of Numbers, Strings or Characters
* or {String}
* @param {Array} of Numbers, Strings or Characters
* @param {Array} pattern of Numbers, Strings or Characters
* or {String}
* @return {Number}
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ var knuthMorrisPratt = function (text, pattern) {
*
* Asymptotic Complexity: O(pattern.length)
*
* @param {Array} of Numbers, Strings or Characters
* @param {Array} pattern of Numbers, Strings or Characters
* or {String}
* @return {Array} of Integers
*/
Expand Down
10 changes: 5 additions & 5 deletions data_structures/linked_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ LinkedList.prototype.isEmpty = function () {
/**
* Adds the element to the end of the list or to the desired index
*
* @param misc
* @param Number
* @param { Object } n
* @param { Number } index
*/
LinkedList.prototype.add = function (n, index) {
if (index > this.length || index < 0) {
Expand Down Expand Up @@ -102,7 +102,7 @@ LinkedList.prototype.add = function (n, index) {
/**
* Return the value associated to the Node on the given index
*
* @param Number
* @param { Number } index
* @return misc
*/
LinkedList.prototype.get = function (index) {
Expand All @@ -112,7 +112,7 @@ LinkedList.prototype.get = function (index) {
/**
* O(n) get
*
* @param Number
* @param { Number } index
* @return Node
*/
LinkedList.prototype.getNode = function (index) {
Expand All @@ -131,7 +131,7 @@ LinkedList.prototype.getNode = function (index) {
/**
* Delete the element in the indexth position
*
* @param Number
* @param { Number } index
*/
LinkedList.prototype.del = function (index) {
if (index >= this.length || index < 0) {
Expand Down
120 changes: 66 additions & 54 deletions test/algorithms/graph/euler_path.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,41 +56,45 @@ var graphFromEdges = function (directed, edges) {

describe('Euler Path', function () {
it('should compute Euler tour over the undirected graph', function () {
var graph = graphFromEdges(false, [[1, 2],
[1, 5],
[1, 7],
[1, 8],
[2, 3],
[2, 4],
[2, 5],
[3, 5],
[4, 6],
[4, 9],
[4, 10],
[5, 6],
[6, 9],
[6, 10],
[7, 8]]);
var graph = graphFromEdges(false, [
[1, 2],
[1, 5],
[1, 7],
[1, 8],
[2, 3],
[2, 4],
[2, 5],
[3, 5],
[4, 6],
[4, 9],
[4, 10],
[5, 6],
[6, 9],
[6, 10],
[7, 8]
]);
var trail = eulerPath(graph);
verifyEulerPath(graph, trail);
assert.equal(trail[0], trail.slice(-1)[0]);
});

it('should compute Euler walk over the undirected graph', function () {
var graph = graphFromEdges(false, [[1, 2],
[1, 5],
[1, 7],
[2, 3],
[2, 4],
[2, 5],
[3, 5],
[4, 6],
[4, 9],
[4, 10],
[5, 6],
[6, 9],
[6, 10],
[7, 8]]);
var graph = graphFromEdges(false, [
[1, 2],
[1, 5],
[1, 7],
[2, 3],
[2, 4],
[2, 5],
[3, 5],
[4, 6],
[4, 9],
[4, 10],
[5, 6],
[6, 9],
[6, 10],
[7, 8]
]);
var trail = eulerPath(graph);
verifyEulerPath(graph, trail);
var endpoints = [trail[0], trail.slice(-1)[0]];
Expand All @@ -100,29 +104,33 @@ describe('Euler Path', function () {
});

it('should compute Euler tour over the directed graph', function () {
var graph = graphFromEdges(true, [[0, 1],
[1, 2],
[2, 0],
[0, 3],
[3, 4],
[4, 0],
[4, 1],
[1, 5],
[5, 6],
[6, 4]]);
var graph = graphFromEdges(true, [
[0, 1],
[1, 2],
[2, 0],
[0, 3],
[3, 4],
[4, 0],
[4, 1],
[1, 5],
[5, 6],
[6, 4]
]);
var trail = eulerPath(graph);
verifyEulerPath(graph, trail);
assert.equal(trail[0], trail.slice(-1)[0]);
});

it('should compute Euler walk over the directed graph', function () {
var graph = graphFromEdges(true, [[5, 0],
[0, 2],
[2, 4],
[4, 0],
[1, 5],
[3, 1],
[5, 3]]);
var graph = graphFromEdges(true, [
[5, 0],
[0, 2],
[2, 4],
[4, 0],
[1, 5],
[3, 1],
[5, 3]
]);
var trail = eulerPath(graph);
assert.deepEqual(trail, [5, 3, 1, 5, 0, 2, 4, 0]);
});
Expand All @@ -143,19 +151,23 @@ describe('Euler Path', function () {
it('should raise an error if there is no Euler path', function () {
var graph = graphFromEdges(false, [[0, 1], [2, 3]]);
assert.throws(eulerPath.bind(graph));
graph = graphFromEdges(false, [[0, 1],
[0, 2],
[0, 3]]);
graph = graphFromEdges(false, [
[0, 1],
[0, 2],
[0, 3]
]);
assert.throws(eulerPath.bind(graph));
graph = graphFromEdges(true, [[0, 1], [0, 2]]);
assert.throws(eulerPath.bind(graph));
graph = graphFromEdges(true, [[1, 0], [2, 0]]);
assert.throws(eulerPath.bind(graph));
graph = graphFromEdges(true, [[0, 1],
[1, 2],
[2, 3],
[3, 0],
[3, 1]]);
graph = graphFromEdges(true, [
[0, 1],
[1, 2],
[2, 3],
[3, 0],
[3, 1]
]);
assert.throws(eulerPath.bind(graph));
});
});
6 changes: 4 additions & 2 deletions test/algorithms/graph/topological_sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ describe('Topological Sort', function () {
var stack = topologicalSort(graph);
var a = [];
while (!stack.isEmpty()) a.push(stack.pop());
assert.deepEqual(a, ['underwear', 'pants', 'socks', 'shoes',
'watch', 'shirt', 'tie', 'belt', 'jacket']);
assert.deepEqual(a, [
'underwear', 'pants', 'socks', 'shoes',
'watch', 'shirt', 'tie', 'belt', 'jacket'
]);
});
});
2 changes: 1 addition & 1 deletion util/comparator.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* If the function is not passed, it will use the default
* compare signs (<, > and ==)
*
* @param Function
* @param { Function } compareFn
*/
function Comparator(compareFn) {
if (compareFn) {
Expand Down

0 comments on commit 713c6f6

Please sign in to comment.