mirror of https://gitee.com/bigwinds/arangodb
added getEdges
This commit is contained in:
parent
3d3132dd87
commit
53854232ef
|
@ -74,6 +74,7 @@
|
|||
/// <li>@ref JSModuleGraphVertexGetId "Vertex.getId"</li>
|
||||
/// <li>@ref JSModuleGraphVertexGetInEdges "Vertex.getInEdges"</li>
|
||||
/// <li>@ref JSModuleGraphVertexGetOutEdges "Vertex.getOutEdges"</li>
|
||||
/// <li>@ref JSModuleGraphVertexGetEdges "Vertex.getEdges"</li>
|
||||
/// <li>@ref JSModuleGraphVertexGetProperty "Vertex.getProperty"</li>
|
||||
/// <li>@ref JSModuleGraphVertexGetPropertyKeys "Vertex.getPropertyKeys"</li>
|
||||
/// <li>@ref JSModuleGraphVertexProperties "Vertex.properties"</li>
|
||||
|
@ -173,6 +174,10 @@
|
|||
/// @copydetails JSF_Vertex_prototype_getOutEdges
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor JSModuleGraphVertexGetEdges
|
||||
/// @copydetails JSF_Vertex_prototype_getEdges
|
||||
/// <hr>
|
||||
///
|
||||
/// @anchor JSModuleGraphVertexGetProperty
|
||||
/// @copydetails JSF_Vertex_prototype_getProperty
|
||||
/// <hr>
|
||||
|
|
|
@ -537,6 +537,28 @@ Vertex.prototype.getOutEdges = function () {
|
|||
return result;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief in- or outbound edges with given label
|
||||
///
|
||||
/// @FUN{@FA{vertex}.getEdges(@FA{label}, ...)}
|
||||
///
|
||||
/// Returns a list of in- or outbound edges of the @FA{vertex} with given
|
||||
/// label(s).
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.getEdges = function () {
|
||||
var labels = Array.prototype.slice.call(arguments),
|
||||
result = this.anybound();
|
||||
|
||||
if (labels.length > 0) {
|
||||
result = result.filter(function (edge) {
|
||||
return (labels.lastIndexOf(edge.getLabel()) > -1);
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns a property of a vertex
|
||||
///
|
||||
|
@ -609,6 +631,22 @@ Vertex.prototype.outbound = function () {
|
|||
});
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief in- or outbound edges
|
||||
///
|
||||
/// @FUN{@FA{vertex}.anybound()}
|
||||
///
|
||||
/// Returns a list of in- or outbound edges of the @FA{vertex}.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Vertex.prototype.anybound = function () {
|
||||
var graph = this._graph;
|
||||
|
||||
return graph._edges.edges(this._id).map(function (result) {
|
||||
return graph.constructEdge(result._id);
|
||||
});
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief returns all properties of a vertex
|
||||
///
|
||||
|
|
|
@ -417,6 +417,7 @@ function VertexSuite() {
|
|||
assertEqual([], v2.getOutEdges());
|
||||
assertEqual(edge.getId(), v1.edges()[0].getId());
|
||||
assertEqual(edge.getId(), v2.edges()[0].getId());
|
||||
assertEqual(1, v1.getEdges().length);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue