Skip to content

Commit

Permalink
renamed transformation arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
mhelvens committed Apr 10, 2015
1 parent efb8235 commit a09cabd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ API Documentation
* [.equals(other, [eq])](#JsGraph#equals) ⇒ <code>boolean</code>
* [.hasCycle()](#JsGraph#hasCycle) ⇒ <code>boolean</code>
* [.hasPath(from, to)](#JsGraph#hasPath) ⇒ <code>boolean</code>
* [.clone([transform])](#JsGraph#clone) ⇒ <code>[JsGraph](#JsGraph)</code>
* [.transitiveReduction([transform])](#JsGraph#transitiveReduction) ⇒ <code>[JsGraph](#JsGraph)</code>
* [.clone([tr])](#JsGraph#clone) ⇒ <code>[JsGraph](#JsGraph)</code>
* [.transitiveReduction([tr])](#JsGraph#transitiveReduction) ⇒ <code>[JsGraph](#JsGraph)</code>
* ___static___
* [.VertexExistsError](#JsGraph.VertexExistsError) ⇐ <code>Error</code>
* [.vertices](#JsGraph.VertexExistsError#vertices) : <code>Set.&lt;{key: string, value}&gt;</code>
Expand Down Expand Up @@ -736,26 +736,26 @@ Test whether there is a directed path between a given pair of keys.
-----

<a name="JsGraph#clone"></a>
#### *jsGraph*.clone([transform]) ⇒ <code>[JsGraph](#JsGraph)</code>
#### *jsGraph*.clone([tr]) ⇒ <code>[JsGraph](#JsGraph)</code>
Create a clone of this graph.


| Param | Type | Description |
| --- | --- | --- |
| [transform] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) |
| [tr] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) |

**Returns**: <code>[JsGraph](#JsGraph)</code> - a clone of this graph

-----

<a name="JsGraph#transitiveReduction"></a>
#### *jsGraph*.transitiveReduction([transform]) ⇒ <code>[JsGraph](#JsGraph)</code>
#### *jsGraph*.transitiveReduction([tr]) ⇒ <code>[JsGraph](#JsGraph)</code>
Create a clone of this graph, but without any transitive edges.


| Param | Type | Description |
| --- | --- | --- |
| [transform] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) |
| [tr] | <code>function</code> | a custom transformation function for stored values; defaults to the identity function; The first argument is the value to clone. If it is a vertex value, the third argument is the vertex key. If it is an edge value, the third and fourth argument are the `from` and `to` keys respectively. (So you can test the fourth argument to distinguish the two cases.) |

**Returns**: <code>[JsGraph](#JsGraph)</code> - a clone of this graph

Expand Down
14 changes: 7 additions & 7 deletions src/js-graph.es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ export default class JsGraph {

/**
* Create a clone of this graph.
* @param [transform] {function(*, string, ?string): *}
* @param [tr] {function(*, string, ?string): *}
* a custom transformation function for stored values; defaults to
* the identity function; The first argument is the value to clone.
* If it is a vertex value, the third argument is the vertex key.
Expand All @@ -802,20 +802,20 @@ export default class JsGraph {
* argument to distinguish the two cases.)
* @returns {JsGraph} a clone of this graph
*/
clone(transform=v=>v) {
clone(tr=v=>v) {
var result = new JsGraph();
for (let [key, val] of this.vertices()) {
result.addVertex(key, transform(val, key));
result.addVertex(key, tr(val, key));
}
for (let [from, to, val] of this.edges()) {
result.addEdge(from, to, transform(val, from, to));
result.addEdge(from, to, tr(val, from, to));
}
return result;
}

/**
* Create a clone of this graph, but without any transitive edges.
* @param [transform] {function(*, string, ?string): *}
* @param [tr] {function(*, string, ?string): *}
* a custom transformation function for stored values; defaults to
* the identity function; The first argument is the value to clone.
* If it is a vertex value, the third argument is the vertex key.
Expand All @@ -824,8 +824,8 @@ export default class JsGraph {
* argument to distinguish the two cases.)
* @returns {JsGraph} a clone of this graph
*/
transitiveReduction(transform=v=>v) {
var result = this.clone(transform);
transitiveReduction(tr=v=>v) {
var result = this.clone(tr);
for (let [x] of this.vertices()) {
for (let [y] of this.vertices()) {
if (result.hasEdge(x, y)) {
Expand Down

0 comments on commit a09cabd

Please sign in to comment.