Comparing version 0.0.3 to 0.0.4
@@ -0,1 +1,11 @@ | ||
v0.0.4 | ||
====== | ||
* Added a value to the graph itself, similar to the values for nodes and edges. | ||
Use `Digraph.graph()` to get the value and `Digraph.graph(x)` to set the | ||
graph's value to `x`. | ||
* Added support for changing the value of node's and edge's by supply | ||
additional value argument. For example, to set the value `x` on node `u`, | ||
call `Digraph.node(u, x)`. | ||
v0.0.3 | ||
@@ -2,0 +12,0 @@ ====== |
@@ -19,2 +19,5 @@ /*! | ||
function Digraph() { | ||
/*! The value assigned to the graph itself */ | ||
this._value = undefined; | ||
/*! Map of nodeId -> {id, value} */ | ||
@@ -80,2 +83,16 @@ this._nodes = {}; | ||
/* | ||
* Accessor for a graph-level value. If called with no arguments this function | ||
* returns the graph value object. If called with the **value** argument this | ||
* function sets the value for the graph, replacing the previous value. | ||
* | ||
* @param {Object} [value] optional value to set for this graph. | ||
*/ | ||
Digraph.prototype.graph = function(value) { | ||
if (arguments.length === 0) { | ||
return this._value; | ||
} | ||
this._value = value; | ||
}; | ||
/* | ||
* Returns `true` if this graph contains a node with the id `u`. Otherwise | ||
@@ -91,9 +108,17 @@ * returns false. | ||
/* | ||
* Returns the value for a node in the graph with the id `u`. If no such node | ||
* is in the graph this function will throw an Error. | ||
* Accessor for node values. If called with a single argument this function | ||
* returns the value for the node **u**. If called with two arguments, this | ||
* function assigns **value** as the value for node **u**. | ||
* | ||
* If no such node is in the graph this function will throw an Error. | ||
* | ||
* @param {String} u a node id | ||
* @param {Object} [value] option value to set for this node | ||
*/ | ||
Digraph.prototype.node = function(u) { | ||
return this._strictGetNode(u).value; | ||
Digraph.prototype.node = function(u, value) { | ||
var node = this._strictGetNode(u); | ||
if (arguments.length === 1) { | ||
return node.value; | ||
} | ||
node.value = value; | ||
}; | ||
@@ -206,9 +231,17 @@ | ||
/* | ||
* Returns the value for an edge with the id `e`. If no such edge exists in | ||
* the graph this function throws an Error. | ||
* Accessor for edge values. If called with a single argument this function | ||
* returns the value for the edge **e**. If called with two arguments, this | ||
* function assigns **value** as the value for edge **e**. | ||
* | ||
* @param {String} e the edge id | ||
* If no such edge is in the graph this function will throw an Error. | ||
* | ||
* @param {String} e an edge id | ||
* @param {Object} [value] option value to set for this node | ||
*/ | ||
Digraph.prototype.edge = function(e) { | ||
return this._strictGetEdge(e).value; | ||
Digraph.prototype.edge = function(e, value) { | ||
var edge = this._strictGetEdge(e); | ||
if (arguments.length === 1) { | ||
return edge.value; | ||
} | ||
edge.value = value; | ||
}; | ||
@@ -319,4 +352,3 @@ | ||
var self = this; | ||
var str = "GRAPH:\n"; | ||
var str = "GRAPH: " + JSON.stringify(self._value) + "\n"; | ||
str += " Nodes:\n"; | ||
@@ -323,0 +355,0 @@ Object.keys(this._nodes) |
@@ -1,1 +0,1 @@ | ||
module.exports = '0.0.3'; | ||
module.exports = '0.0.4'; |
{ | ||
"name": "graphlib", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "A multi-graph library", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -17,6 +17,8 @@ # Graphlib | ||
# Build / Install | ||
# Getting Graphlib | ||
Before building this library you need to install the [npm package manager]. | ||
## NPM Install | ||
Before installing this library you need to install the [npm package manager]. | ||
To get graphlib from npm, use: | ||
@@ -26,2 +28,19 @@ | ||
## Browser Scripts | ||
You can get the latest browser-ready scripts: | ||
* [graphlib.js](http://cpettitt.github.io/project/graphlib/latest/graphlib.js) | ||
* [graphlib.min.js](http://cpettitt.github.io/project/graphlib/latest/graphlib.min.js) | ||
## Build From Source | ||
Before building this library you need to install the [npm package manager]. | ||
Check out this project and run this command from the root of the project: | ||
$ make | ||
This will generate `graphlib.js` and `graphlib.min.js` in the root of the project. | ||
# Example | ||
@@ -89,3 +108,3 @@ | ||
[API documentation](http://cpettitt.github.io/project/graphlib/doc/index.html) | ||
[API documentation](http://cpettitt.github.io/project/graphlib/latest/doc/index.html) | ||
@@ -92,0 +111,0 @@ ## |
Sorry, the diff of this file is not supported yet
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
22534
533
116
0