1
0
Fork 0

Graph: Replace a given edge by ID

This commit is contained in:
Lucas Dohmen 2013-10-31 15:12:06 +01:00
parent 04c7cfce33
commit 6049ef11fb
4 changed files with 44 additions and 0 deletions

View File

@ -287,6 +287,14 @@ Graph.prototype._replaceVertex = function (id, data) {
GraphAPI.putVertex(this._properties._key, id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief replace an edge in the graph
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._replaceEdge = function (id, data) {
GraphAPI.putEdge(this._properties._key, id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns a vertex given its id
////////////////////////////////////////////////////////////////////////////////

View File

@ -793,6 +793,18 @@ Graph.prototype.replaceVertex = function (id, data) {
this._replaceVertex(id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief replaces an existing edge by ID
///
/// @FUN{@FA{graph}.replaceEdge(@FA{id}, @FA{data})}
///
/// Replaces an existing edge by ID
////////////////////////////////////////////////////////////////////////////////
Graph.prototype.replaceEdge = function (id, data) {
this._replaceEdge(id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns the number of vertices
///

View File

@ -239,6 +239,22 @@ function GraphBasicsSuite() {
assertEqual(edge._properties._key, edge.getId());
},
testReplaceEdge : function () {
var v1,
v2,
edge;
v1 = graph.addVertex("vertex1");
v2 = graph.addVertex("vertex2");
graph.addEdge(v1, v2, "my-edge");
graph.replaceEdge("my-edge", { weight: 2 });
edge = graph.getEdge("my-edge");
assertEqual(2, edge.getProperty("weight"));
},
////////////////////////////////////////////////////////////////////////////////
/// @brief change a property
////////////////////////////////////////////////////////////////////////////////

View File

@ -602,6 +602,14 @@ Graph.prototype._replaceVertex = function (vertex_id, data) {
var result = this._vertices.replace(vertex_id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief replaces an edge in the graph
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._replaceEdge = function (edge_id, data) {
var result = this._edges.replace(edge_id, data);
};
////////////////////////////////////////////////////////////////////////////////
/// @brief returns a vertex given its id
///