Comparing version 0.1.0 to 0.2.0
@@ -105,2 +105,7 @@ (function () | ||
{ | ||
// set('a', '-b', ...) is a synonym for dir('a', 'b', ...) | ||
if (v[0] == '-') { | ||
return this.dir(u, v.substr(1), edge); | ||
} | ||
// take an undefined edge as simply 'true' for convenience | ||
@@ -107,0 +112,0 @@ edge = (edge === undefined ? true : edge); |
{ | ||
"name": "graph", | ||
"description": "library for manipulating directed and undirected graphs", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"homepage": "http://github.johntantalo.com/graphjs/", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -36,2 +36,6 @@ # GraphJS | ||
#### With directed edges | ||
new Graph({a: ['-b', '-c']}); # Directed edges to b and c. | ||
### Degree, size, order, and adjacency | ||
@@ -62,3 +66,7 @@ | ||
g.has('b', 'a'); # false | ||
#### Alternative syntax | ||
g.set('a', '-b'); # Same as g.dir('a', 'b'); | ||
### Deleting directed edges | ||
@@ -65,0 +73,0 @@ |
@@ -186,2 +186,30 @@ if (typeof(require) !== 'undefined') { | ||
'Constructor with directed edges': function (test) | ||
{ | ||
var g = new Graph({'a': ['-b', '-c']}); | ||
test.ok(g.order() === 3, | ||
"Number of vertices is 3."); | ||
test.ok(g.size() === 2, | ||
"Number of edges is 2."); | ||
test.ok(g.degree('a') === 2, | ||
"Out degree of 'a' is 1."); | ||
test.ok(g.degree('b') === 0, | ||
"Out degree of 'b' is 0."); | ||
test.ok(g.degree('c') === 0, | ||
"Out degree of 'c' is 0."); | ||
test.ok(g.indegree('a') === 0, | ||
"In degree of 'a' is 0."); | ||
test.ok(g.indegree('b') === 1, | ||
"In degree of 'b' is 1."); | ||
test.ok(g.indegree('c') === 1, | ||
"In degree of 'c' is 1."); | ||
test.ok(g.has('a', 'b')); | ||
test.ok(g.has('a', 'c')); | ||
test.ok(!g.has('b', 'a')); | ||
test.ok(!g.has('c', 'a')); | ||
test.ok(!g.has('c', 'b')); | ||
test.ok(!g.has('b', 'c')); | ||
test.done(); | ||
}, | ||
'Multiget': function (test) | ||
@@ -188,0 +216,0 @@ { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
124447
3512
108
0
1