Permalink
Browse files

Add graph.from and node.to

  • Loading branch information...
1 parent 39d75d1 commit 3022587a1f56d988f8b7f2831f0cee77066a68b1 @glejeune committed Oct 15, 2010
Showing with 17 additions and 1 deletion.
  1. +1 −0 README.rdoc
  2. +8 −1 lib/deps/graph.js
  3. +8 −0 lib/deps/node.js
View
@@ -21,6 +21,7 @@ Interface to the GraphViz graphing tool
* Update Attributs class
* parse now accept a file or a script
* Update render (see tests/hello.js)
+* Add graph.from and node.to (see tests/compound.js)
=== 0.0.3 :
View
@@ -66,6 +66,13 @@ Graph.prototype.getNode = function(id) {
return this.nodes.items[id];
}
+Graph.prototype.from = function(id) {
+ if( this.nodes.items[id] == undefined ) {
+ this.addNode(id);
+ }
+ return this.nodes.items[id];
+}
+
/**
* Return the number of nodes in the current graph
*
@@ -219,7 +226,7 @@ Graph.prototype.setEdgeAttribut = function(name, value) {
* @return {Void}
* @api public
*/
-Graph.prototype.getNodeAttribut = function(name) {
+Graph.prototype.getEdgeAttribut = function(name) {
return this.edgesAttributs.get(name);
}
View
@@ -19,6 +19,14 @@ var Node = exports.Node = function(graph, id) {
};
/**
+ *
+ */
+Node.prototype.to = function(id, attrs) {
+ this.relativeGraph.addEdge(this, id, attrs)
+ return this.relativeGraph.from(id);
+}
+
+/**
* Set a node attribut
*
* @param {String} name The attribut name

0 comments on commit 3022587

Please sign in to comment.