Skip to content

Commit 1631de5

Browse files
committed
updated README to include what the addNieghbors function should return.
1 parent 80faf22 commit 1631de5

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Is represented in memory as:
4949
The basic operations provided by a graph data structure usually include:
5050

5151
1. Define a `Node` class that has a `name {{string}}`, `value{{*}}`, and `neighbors{{array}}`
52-
1. `Node.addNeighbors([x {{node}}, y {{node}}, z {{node}} ...])`: adds an array of nodes x, y, z to `node`.
52+
1. `Node.addNeighbors([x {{node}}, y {{node}}, z {{node}} ...])`: adds an array of nodes x, y, z to `node`. Return an array with all of the nodes neighbors.
5353
1. `Node.neighbors(x {{node}})`: lists all vertices such that there is an edge from the vertices x to y.
5454
1. `Node.toString()`: returns the name of the node as a String.
5555
1. [Optional] `Node.removeNode(x {{node}})`: removes the vertex x, if it is there.

graphGenerator.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
// Implement a graph generator that represents a set of objects where some pairs of objects are connected by links.
2-
31
const Node = function(name, value) {
42

53
}
64

75

8-
module.exports = Node;
6+
module.exports = Node;

test/graph-traversal.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ describe('Graph Generator', () => {
1313
D = new Node("D", "JSON");
1414
E = new Node("E", "Marifel");
1515
F = new Node("F", "Nigel");
16-
A.addNeighbors([B, C]);
17-
B.addNeighbors([D, E]);
18-
C.addNeighbors([F]);
1916
});
2017

2118
it('should be a function that exists', () => {
@@ -56,6 +53,9 @@ describe('Graph Generator', () => {
5653
expect(C.addNeighbors()).to.exist;
5754
});
5855
it('Node `neighbors` should refernce other neighbors', () => {
56+
A.addNeighbors([B, C]);
57+
B.addNeighbors([D, E]);
58+
C.addNeighbors([F]);
5959
expect(A.neighbors[0].name).to.equal('B');
6060
expect(A.neighbors[0].value).to.equal('Jon');
6161
expect(A.neighbors[0].neighbors[0].name).to.equal('D');

0 commit comments

Comments
 (0)