graphs-all
Advanced tools
Comparing version 0.0.0-semantic-release to 0.0.0
{ | ||
"name": "graphs-all", | ||
"version": "0.0.0-semantic-release", | ||
"version": "0.0.0", | ||
"description": "Graph Data Structure Library", | ||
@@ -46,2 +46,2 @@ "main": "src/index.js", | ||
} | ||
} | ||
} |
@@ -66,2 +66,15 @@ function Graph(isDirected, isWeighted) { | ||
this.removeLink = function(key1, key2) { | ||
if (!this.hasLink(key1, key2)) { | ||
return false; | ||
} | ||
var id1 = keyToIdTable[key1], | ||
id2 = keyToIdTable[key2]; | ||
delete this.links[id1][id2]; | ||
if (!isDirected) { | ||
delete this.links[id2][id1]; | ||
} | ||
return true; | ||
}; | ||
this.linkWeight = function (key1, key2) { | ||
@@ -68,0 +81,0 @@ if (!this.hasLink(key1, key2)) { |
@@ -61,3 +61,5 @@ var expect = require("chai").expect; | ||
g.addNode("Three", 3); | ||
g.addNode("Five", 5); | ||
g.addLink("One", "Two"); | ||
g.addLink("One", "Five"); | ||
expect(g.hasLink("One", "Two")).to.be.true; | ||
@@ -76,2 +78,9 @@ expect(g.hasLink("Two", "One")).to.be.true; | ||
// Remove | ||
expect(g.removeLink("One", "Two")).to.be.true; | ||
expect(g.hasLink("One", "Two")).to.be.false; | ||
expect(g.hasLink("Two", "One")).to.be.false; | ||
expect(g.removeLink("One", "Two")).to.be.false; | ||
expect(g.linkWeight("Two", "One")).to.be.undefined; | ||
}) | ||
@@ -78,0 +87,0 @@ }) |
9370
173