Skip to content

Commit

Permalink
Console.logs and new node to example
Browse files Browse the repository at this point in the history
  • Loading branch information
brunolnetto committed Jan 12, 2022
1 parent 8ca92db commit 5731932
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@
"npm": ">=6.9.0"
}
}

4 changes: 1 addition & 3 deletions src/data-structures/graph/Graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,7 @@ export default class Graph {

if (visited[index])
return false;

console.log(index);


visited[index] = true;
recStack[index] = true;

Expand Down
6 changes: 5 additions & 1 deletion src/data-structures/graph/__test__/GraphVertex.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,14 @@ describe('GraphVertex', () => {

it('should represent a vertex', () => {
const vertex = new GraphVertex('A');
console.log(vertex.toString())
expect(vertex.toString()).toEqual('A');
});

it('should represent a vertex with decorator', () => {
const vertex = new GraphVertex('A');
expect(vertex.toString((value) => `Name: ${value}`)).toEqual('Name: A');
});

it('should calculate vertex degree', () => {
const vertexA = new GraphVertex('A');
const vertexB = new GraphVertex('B');
Expand Down
10 changes: 8 additions & 2 deletions src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,25 @@ app.get('/', (req, res) => {
let C = new GraphVertex('C');
let D = new GraphVertex('D');
let E = new GraphVertex('E');
let F = new GraphVertex('F');

// Vertices
let AB = new GraphEdge(A, B);
let BC = new GraphEdge(B, C);
let CD = new GraphEdge(C, D);
let CE = new GraphEdge(C, E);
let EB = new GraphEdge(E, B);
let CF = new GraphEdge(C, F);
let FB = new GraphEdge(F, B);

// Add vertices
graph_.addVertices([A, B, C, D, E]);
graph_.addVertices([A, B, C, D, E, F]);

// Add edges
graph_.addEdges([AB, BC, CD, CE, EB]);
graph_.addEdges([AB, BC, CD, CE, EB, CF, FB]);

let from = A;
let to = D;

res.send(graph_.describe());
});
Expand Down

0 comments on commit 5731932

Please sign in to comment.