mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel
This commit is contained in:
commit
2b682769e7
|
@ -1,10 +1,19 @@
|
|||
!CHAPTER Fluent AQL Interface
|
||||
|
||||
TODO: write intro
|
||||
This chapter describes a fluent interface to query your graph.
|
||||
The philosophy of this interface is to at first select a group of starting elements (vertices or edges) and from there on explore the graph with your query by selecting connected elements.
|
||||
As an example you can start with a set of vertices, select their direct neighbors and finally their outgoing edges.
|
||||
The result of this query will be the set of outgoing edges.
|
||||
For each part of the query it is possible to further refine the resulting set of elements by giving examples for them.
|
||||
|
||||
!SECTION Starting Points
|
||||
|
||||
TODO: write intro
|
||||
This section describes the entry points for the fluent interface.
|
||||
In the philosophy of this module you have to start with a specific subset of vertices or edges and from there on iterate over the graph.
|
||||
Therefore you get exactly this two entry points:
|
||||
|
||||
* Select a set of edges
|
||||
* Select a set of vertices
|
||||
|
||||
!SUBSECTION Edges
|
||||
|
||||
|
@ -24,7 +33,7 @@ The resulting set of edges can be filtered by defining one or more `examples`.
|
|||
* A string, only the edge having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only edges having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All edges matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -67,7 +76,7 @@ The resulting set of edges can be filtered by defining one or more `examples`.
|
|||
* A string, only the vertex having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only vertices having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All vertices matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -94,6 +103,14 @@ g._vertices([{name: "Alice"}, {name: "Bob"}]).toArray();
|
|||
|
||||
!SECTION Fluent query options
|
||||
|
||||
After the selection of the entry point you can now query your graph in
|
||||
a fluent way, meaning each of the functions on your query returns the query again.
|
||||
Hence it is possible to chain arbitrary many executions one after the other.
|
||||
The query object itself handles cursor creation and maintenance for you.
|
||||
A cursor will be created as soon as you request the first result.
|
||||
If you are unhappy with the current result and want to refine it further you can execute a further step in the query which cleans up the cursor for you.
|
||||
In this interface you get the complete functionality available for general AQL cursors directly on your query.
|
||||
|
||||
!SUBSECTION ToArray
|
||||
|
||||
<!-- @startDocuBlock JSF_general_graph_fluent_aql_toArray -->
|
||||
|
@ -236,7 +253,7 @@ The resulting set of edges can be filtered by defining one or more `examples`.
|
|||
* A string, only the edge having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only edges having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All edges matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -287,7 +304,7 @@ The resulting set of edges can be filtered by defining one or more `examples`.
|
|||
* A string, only the edge having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only edges having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All edges matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -338,7 +355,7 @@ The resulting set of edges can be filtered by defining one or more `examples`.
|
|||
* A string, only the edge having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only edges having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All edges matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -390,7 +407,7 @@ The resulting set of vertices can be filtered by defining one or more `examples`
|
|||
* A string, only the vertex having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only vertices having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All vertices matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -442,7 +459,7 @@ The resulting set of vertices can be filtered by defining one or more `examples`
|
|||
* A string, only the vertex having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only vertices having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All vertices matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -494,7 +511,7 @@ The resulting set of vertices can be filtered by defining one or more `examples`
|
|||
* A string, only the vertex having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only vertices having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All vertices matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -545,7 +562,7 @@ The resulting set of vertices can be filtered by defining one or more `examples`
|
|||
* A string, only the vertex having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only vertices having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All vertices matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
@ -643,7 +660,7 @@ The result set is reduced to the set of elements that matches the given `example
|
|||
* A string, only the elements having this value as it's id is returned.
|
||||
* An example object, defining a set of attributes.
|
||||
Only elements having these attributes are matched.
|
||||
* A list containing example objects andor strings.
|
||||
* A list containing example objects and/or strings.
|
||||
All elements matching at least one of the elements in the list are returned.
|
||||
<br />
|
||||
@EXAMPLES
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
!CHAPTER General Graphs
|
||||
|
||||
This chapter describes the multi-collection graph module.
|
||||
It allows you to define a graph that is spread across several edge and document collections.
|
||||
This allows you to structure your models in line with your domain and group them logically in collections and giving you the power to query them in the same graph queries.
|
||||
There is no need to include the referenced collections within the query, this module will handle it for you.
|
|
@ -68,6 +68,7 @@
|
|||
* [Edge Methods](Blueprint-Graphs/EdgeMethods.md)
|
||||
<!-- 13.5 -->
|
||||
* [General-Graphs](General-Graphs/README.md)
|
||||
* [Graph Functions](General-Graphs/GeneralGraphFunctions.md)
|
||||
* [Fluent AQL Interface](General-Graphs/FluentAQLInterface.md)
|
||||
<!-- 14 -->
|
||||
* [Traversals](Traversals/README.md)
|
||||
|
|
|
@ -2018,8 +2018,6 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example,
|
|||
"ex2": ex2
|
||||
};
|
||||
return db._query(query, bindVars, {count: true}).toArray();
|
||||
|
||||
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1408,7 +1408,7 @@ function ChainedFluentAQLResultsSuite() {
|
|||
test_getExampleNeighborsOfSelectedVerticesResultingAQL: function() {
|
||||
var query = g._vertices({name: uaName})
|
||||
.neighbors([{
|
||||
name: uaName
|
||||
name: ubName
|
||||
},{
|
||||
name: p1Name
|
||||
}]);
|
||||
|
@ -1420,31 +1420,27 @@ function ChainedFluentAQLResultsSuite() {
|
|||
assertEqual(query.bindVars.options_0, {});
|
||||
assertEqual(query.bindVars.options_1, {
|
||||
neighborExamples: [{
|
||||
name: uaName
|
||||
name: ubName
|
||||
},{
|
||||
name: p1Name
|
||||
}]
|
||||
});
|
||||
},
|
||||
|
||||
/* Not yet working, neighbors requires vertex-examples in AQL
|
||||
|
||||
test_getExampleNeighborsOfSelectedVertices: function() {
|
||||
var result = g._vertices({name: uaName})
|
||||
.neighbors([{
|
||||
name: uaName
|
||||
name: ubName
|
||||
},{
|
||||
name: p1Name
|
||||
}])
|
||||
.toArray();
|
||||
assertEqual(result.length, 2);
|
||||
var sorted = _.sortBy(result, "name");
|
||||
assertEqual(sorted[0].name, uaName);
|
||||
assertEqual(sorted[0].name, ubName);
|
||||
assertEqual(sorted[1].name, p1Name);
|
||||
},
|
||||
|
||||
*/
|
||||
|
||||
test_getEdgesOfNeighborsResultingAQL: function() {
|
||||
var query = g._vertices({name: uaName})
|
||||
.neighbors()
|
||||
|
@ -1940,10 +1936,26 @@ function EdgesAndVerticesSuite() {
|
|||
|
||||
|
||||
function GeneralGraphCommonNeighborsSuite() {
|
||||
var vertex = null;
|
||||
var edge = null;
|
||||
var testGraph, actual;
|
||||
|
||||
var v1ColName = "UnitTestsAhuacatlVertex1";
|
||||
var v2ColName = "UnitTestsAhuacatlVertex2";
|
||||
var eColName = "UnitTestsAhuacatlEdge1";
|
||||
var v1;
|
||||
var v2;
|
||||
var v3;
|
||||
var v4;
|
||||
var v5;
|
||||
var v6;
|
||||
var v7;
|
||||
var v8;
|
||||
|
||||
var createKeyValueObject = function(key, value) {
|
||||
var res = {};
|
||||
res[key] = value;
|
||||
return res;
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1951,48 +1963,48 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
setUp: function () {
|
||||
db._drop("UnitTestsAhuacatlVertex1");
|
||||
db._drop("UnitTestsAhuacatlVertex2");
|
||||
db._drop("UnitTestsAhuacatlEdge1");
|
||||
db._drop(v1ColName);
|
||||
db._drop(v2ColName);
|
||||
db._drop(eColName);
|
||||
|
||||
vertex1 = db._create("UnitTestsAhuacatlVertex1");
|
||||
vertex2 = db._create("UnitTestsAhuacatlVertex2");
|
||||
edge1 = db._createEdgeCollection("UnitTestsAhuacatlEdge1");
|
||||
var vertex1 = db._create(v1ColName);
|
||||
var vertex2 = db._create(v2ColName);
|
||||
var edge1 = db._createEdgeCollection(eColName);
|
||||
|
||||
vertex1.save({ _key: "v1" , hugo : true});
|
||||
vertex1.save({ _key: "v2" ,hugo : true});
|
||||
vertex1.save({ _key: "v3" , heinz : 1});
|
||||
vertex1.save({ _key: "v4" , harald : "meier"});
|
||||
vertex2.save({ _key: "v5" , ageing : true});
|
||||
vertex2.save({ _key: "v6" , harald : "meier", ageing : true});
|
||||
vertex2.save({ _key: "v7" ,harald : "meier"});
|
||||
vertex2.save({ _key: "v8" ,heinz : 1, harald : "meier"});
|
||||
v1 = vertex1.save({ _key: "v1" , hugo : true})._id;
|
||||
v2 = vertex1.save({ _key: "v2" ,hugo : true})._id;
|
||||
v3 = vertex1.save({ _key: "v3" , heinz : 1})._id;
|
||||
v4 = vertex1.save({ _key: "v4" , harald : "meier"})._id;
|
||||
v5 = vertex2.save({ _key: "v5" , ageing : true})._id;
|
||||
v6 = vertex2.save({ _key: "v6" , harald : "meier", ageing : true})._id;
|
||||
v7 = vertex2.save({ _key: "v7" ,harald : "meier"})._id;
|
||||
v8 = vertex2.save({ _key: "v8" ,heinz : 1, harald : "meier"})._id;
|
||||
|
||||
function makeEdge(from, to, collection) {
|
||||
collection.save(from, to, { what: from.split("/")[1] + "->" + to.split("/")[1] });
|
||||
}
|
||||
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v1", "UnitTestsAhuacatlVertex1/v2", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v2", "UnitTestsAhuacatlVertex1/v3", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v5", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v2", "UnitTestsAhuacatlVertex2/v6", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex2/v6", "UnitTestsAhuacatlVertex2/v7", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v4", "UnitTestsAhuacatlVertex2/v7", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v7", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex2/v8", "UnitTestsAhuacatlVertex1/v1", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v5", edge1);
|
||||
makeEdge("UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v8", edge1);
|
||||
makeEdge(v1, v2, edge1);
|
||||
makeEdge(v2, v3, edge1);
|
||||
makeEdge(v3, v5, edge1);
|
||||
makeEdge(v2, v6, edge1);
|
||||
makeEdge(v6, v7, edge1);
|
||||
makeEdge(v4, v7, edge1);
|
||||
makeEdge(v3, v7, edge1);
|
||||
makeEdge(v8, v1, edge1);
|
||||
makeEdge(v3, v5, edge1);
|
||||
makeEdge(v3, v8, edge1);
|
||||
|
||||
try {
|
||||
db._collection("_graphs").remove("_graphs/bla3")
|
||||
} catch (err) {
|
||||
db._collection("_graphs").remove("_graphs/bla3");
|
||||
} catch (ignore) {
|
||||
}
|
||||
testGraph = graph._create(
|
||||
"bla3",
|
||||
graph._edgeDefinitions(
|
||||
graph._directedRelationDefinition("UnitTestsAhuacatlEdge1",
|
||||
["UnitTestsAhuacatlVertex1", "UnitTestsAhuacatlVertex2"],
|
||||
["UnitTestsAhuacatlVertex1", "UnitTestsAhuacatlVertex2"]
|
||||
graph._directedRelationDefinition(eColName,
|
||||
[v1ColName, v2ColName],
|
||||
[v1ColName, v2ColName]
|
||||
)
|
||||
)
|
||||
);
|
||||
|
@ -2003,12 +2015,12 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
tearDown: function () {
|
||||
db._drop("UnitTestsAhuacatlVertex1");
|
||||
db._drop("UnitTestsAhuacatlVertex2");
|
||||
db._drop("UnitTestsAhuacatlEdge1");
|
||||
db._drop(v1ColName);
|
||||
db._drop(v2ColName);
|
||||
db._drop(eColName);
|
||||
try {
|
||||
db._collection("_graphs").remove("_graphs/bla3")
|
||||
} catch (err) {
|
||||
db._collection("_graphs").remove("_graphs/bla3");
|
||||
} catch (ignore) {
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -2017,14 +2029,11 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCommonNeighborsAny: function () {
|
||||
actual = testGraph._listCommonNeighbors('UnitTestsAhuacatlVertex1/v3' , 'UnitTestsAhuacatlVertex2/v6', {direction : 'any'});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v7");
|
||||
|
||||
|
||||
actual = testGraph._amountCommonNeighbors('UnitTestsAhuacatlVertex1/v3' , 'UnitTestsAhuacatlVertex2/v6', {direction : 'any'});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"][0]["UnitTestsAhuacatlVertex2/v6"] , 2);
|
||||
|
||||
actual = testGraph._listCommonNeighbors(v3 , v6, {direction : 'any'});
|
||||
assertEqual(actual[0][v3][v6][0]._id , v2);
|
||||
assertEqual(actual[0][v3][v6][1]._id , v7);
|
||||
actual = testGraph._amountCommonNeighbors(v3 , v6, {direction : 'any'});
|
||||
assertEqual(actual[0][v3][0][v6] , 2);
|
||||
},
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief checks GRAPH_COMMON_NEIGHBORS()
|
||||
|
@ -2032,28 +2041,25 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
|
||||
testCommonNeighborsIn: function () {
|
||||
actual = testGraph._listCommonNeighbors({} , {}, {direction : 'inbound'});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
|
||||
|
||||
assertEqual(actual[2]["UnitTestsAhuacatlVertex2/v6"]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[0][v3][v6][0]._id, v2);
|
||||
assertEqual(actual[1][v5][v8][0]._id, v3);
|
||||
assertEqual(actual[1][v5][v7][0]._id, v3);
|
||||
assertEqual(actual[2][v6][v3][0]._id, v2);
|
||||
assertEqual(actual[3][v7][v5][0]._id, v3);
|
||||
assertEqual(actual[3][v7][v8][0]._id, v3);
|
||||
assertEqual(actual[4][v8][v5][0]._id, v3);
|
||||
assertEqual(actual[4][v8][v7][0]._id, v3);
|
||||
|
||||
actual = testGraph._amountCommonNeighbors({} , {}, {direction : 'inbound'});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"][0]["UnitTestsAhuacatlVertex2/v6"] , 1);
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"][0]["UnitTestsAhuacatlVertex2/v8"] , 1);
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v5"][1]["UnitTestsAhuacatlVertex2/v7"] , 1);
|
||||
assertEqual(actual[2]["UnitTestsAhuacatlVertex2/v6"][0]["UnitTestsAhuacatlVertex1/v3"] , 1);
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"][0]["UnitTestsAhuacatlVertex2/v5"] , 1);
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v7"][1]["UnitTestsAhuacatlVertex2/v8"] , 1);
|
||||
assertEqual(actual[0][v3][0][v6] , 1);
|
||||
assertEqual(actual[1][v5][0][v8] , 1);
|
||||
assertEqual(actual[1][v5][1][v7] , 1);
|
||||
assertEqual(actual[2][v6][0][v3] , 1);
|
||||
assertEqual(actual[3][v7][0][v5] , 1);
|
||||
assertEqual(actual[3][v7][1][v8] , 1);
|
||||
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"][0]["UnitTestsAhuacatlVertex2/v5"] , 1);
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"][1]["UnitTestsAhuacatlVertex2/v7"] , 1);
|
||||
assertEqual(actual[4][v8][0][v5] , 1);
|
||||
assertEqual(actual[4][v8][1][v7] , 1);
|
||||
|
||||
},
|
||||
|
||||
|
@ -2063,26 +2069,30 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCommonNeighborsOut: function () {
|
||||
actual = testGraph._listCommonNeighbors( { hugo : true } , {heinz : 1}, {direction : 'outbound', minDepth : 1, maxDepth : 3});
|
||||
assertEqual(Object.keys(actual[1])[0] , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(Object.keys(actual[1][Object.keys(actual[1])[0]]) , ["UnitTestsAhuacatlVertex2/v8", "UnitTestsAhuacatlVertex1/v3"]);
|
||||
actual = testGraph._listCommonNeighbors(
|
||||
{hugo: true}, {heinz: 1},
|
||||
{direction: 'outbound', minDepth: 1, maxDepth: 3}
|
||||
);
|
||||
assertEqual(Object.keys(actual[1])[0], v2);
|
||||
assertEqual(Object.keys(actual[1][Object.keys(actual[1])[0]]), [v8, v3]);
|
||||
|
||||
assertEqual(actual[1][Object.keys(actual[1])[0]]["UnitTestsAhuacatlVertex2/v8"].length , 3);
|
||||
assertEqual(actual[1][Object.keys(actual[1])[0]]["UnitTestsAhuacatlVertex1/v3"].length , 4);
|
||||
assertEqual(actual[1][Object.keys(actual[1])[0]][v8].length, 3);
|
||||
assertEqual(actual[1][Object.keys(actual[1])[0]][v3].length, 4);
|
||||
|
||||
assertEqual(Object.keys(actual[0])[0] , "UnitTestsAhuacatlVertex1/v1");
|
||||
assertEqual(Object.keys(actual[0][Object.keys(actual[0])[0]]) , ["UnitTestsAhuacatlVertex1/v3", "UnitTestsAhuacatlVertex2/v8"]);
|
||||
|
||||
assertEqual(actual[0][Object.keys(actual[0])[0]]["UnitTestsAhuacatlVertex1/v3"].length , 4);
|
||||
assertEqual(actual[0][Object.keys(actual[0])[0]]["UnitTestsAhuacatlVertex2/v8"].length , 3);
|
||||
|
||||
actual = testGraph._amountCommonNeighbors({ hugo : true } , {heinz : 1}, {direction : 'outbound', minDepth : 1, maxDepth : 3});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]["UnitTestsAhuacatlVertex1/v3"] , 4);
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][1]["UnitTestsAhuacatlVertex2/v8"] , 3);
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]["UnitTestsAhuacatlVertex2/v8"] , 3);
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][1]["UnitTestsAhuacatlVertex1/v3"] , 4);
|
||||
assertEqual(Object.keys(actual[0])[0], v1);
|
||||
assertEqual(Object.keys(actual[0][Object.keys(actual[0])[0]]), [v3, v8]);
|
||||
|
||||
assertEqual(actual[0][Object.keys(actual[0])[0]][v3].length, 4);
|
||||
assertEqual(actual[0][Object.keys(actual[0])[0]][v8].length, 3);
|
||||
|
||||
actual = testGraph._amountCommonNeighbors(
|
||||
{hugo: true }, {heinz: 1},
|
||||
{direction: 'outbound', minDepth: 1, maxDepth: 3}
|
||||
);
|
||||
assertEqual(actual[0][v1][0][v3], 4);
|
||||
assertEqual(actual[0][v1][1][v8], 3);
|
||||
assertEqual(actual[1][v2][0][v8], 3);
|
||||
assertEqual(actual[1][v2][1][v3], 4);
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -2090,78 +2100,50 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testCommonProperties: function () {
|
||||
actual = testGraph._listCommonProperties( { } , {}, {});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]._id , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]._id , "UnitTestsAhuacatlVertex1/v1");
|
||||
assertEqual(actual[2]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][0]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][1]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex1/v4"][2]._id , "UnitTestsAhuacatlVertex2/v7");
|
||||
actual = testGraph._listCommonProperties({} ,{} ,{});
|
||||
assertEqual(actual[0][v1][0]._id , v2);
|
||||
assertEqual(actual[1][v2][0]._id , v1);
|
||||
assertEqual(actual[2][v3][0]._id , v8);
|
||||
assertEqual(actual[3][v4][0]._id , v6);
|
||||
assertEqual(actual[3][v4][1]._id , v8);
|
||||
assertEqual(actual[3][v4][2]._id , v7);
|
||||
assertEqual(actual[4][v5][0]._id , v6);
|
||||
assertEqual(actual[5][v6][0]._id , v4);
|
||||
assertEqual(actual[5][v6][1]._id , v5);
|
||||
assertEqual(actual[5][v6][2]._id , v8);
|
||||
assertEqual(actual[5][v6][3]._id , v7);
|
||||
assertEqual(actual[6][v7][0]._id , v4);
|
||||
assertEqual(actual[6][v7][1]._id , v6);
|
||||
assertEqual(actual[6][v7][2]._id , v8);
|
||||
assertEqual(actual[7][v8][0]._id , v3);
|
||||
assertEqual(actual[7][v8][1]._id , v4);
|
||||
assertEqual(actual[7][v8][2]._id , v6);
|
||||
assertEqual(actual[7][v8][3]._id , v7);
|
||||
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v4");
|
||||
assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v5");
|
||||
assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][2]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v6"][3]._id , "UnitTestsAhuacatlVertex2/v7");
|
||||
|
||||
|
||||
assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][0]._id , "UnitTestsAhuacatlVertex1/v4");
|
||||
assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][1]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
assertEqual(actual[6]["UnitTestsAhuacatlVertex2/v7"][2]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
|
||||
assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][1]._id , "UnitTestsAhuacatlVertex1/v4");
|
||||
assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][2]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
assertEqual(actual[7]["UnitTestsAhuacatlVertex2/v8"][3]._id , "UnitTestsAhuacatlVertex2/v7");
|
||||
|
||||
|
||||
actual = testGraph._amountCommonProperties( { } , {}, {});
|
||||
actual = testGraph._amountCommonProperties({} ,{} ,{});
|
||||
assertEqual(actual, [
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v1" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v2" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v3" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v4" : 3
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v5" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v6" : 4
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v7" : 3
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v8" : 4
|
||||
}
|
||||
createKeyValueObject(v1, 1),
|
||||
createKeyValueObject(v2, 1),
|
||||
createKeyValueObject(v3, 1),
|
||||
createKeyValueObject(v4, 3),
|
||||
createKeyValueObject(v5, 1),
|
||||
createKeyValueObject(v6, 4),
|
||||
createKeyValueObject(v7, 3),
|
||||
createKeyValueObject(v8, 4)
|
||||
]);
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
testCommonPropertiesWithFilters: function () {
|
||||
actual = testGraph._listCommonProperties({ageing : true} , {harald : 'meier'}, {});
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex1/v4");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][1]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex2/v6"][2]._id , "UnitTestsAhuacatlVertex2/v7");
|
||||
assertEqual(actual[0][v5][0]._id , v6);
|
||||
assertEqual(actual[1][v6][0]._id , v4);
|
||||
assertEqual(actual[1][v6][1]._id , v8);
|
||||
assertEqual(actual[1][v6][2]._id , v7);
|
||||
|
||||
actual = testGraph._amountCommonProperties({ageing : true} , {harald : 'meier'}, {});
|
||||
assertEqual(actual, [
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v5" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v6" : 3
|
||||
}
|
||||
createKeyValueObject(v5, 1),
|
||||
createKeyValueObject(v6, 3)
|
||||
]);
|
||||
|
||||
},
|
||||
|
@ -2169,40 +2151,24 @@ function GeneralGraphCommonNeighborsSuite() {
|
|||
testCommonPropertiesWithFiltersAndIgnoringKeyHarald: function () {
|
||||
actual = testGraph._listCommonProperties( {} , {}, {ignoreProperties : 'harald'});
|
||||
|
||||
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v1"][0]._id , "UnitTestsAhuacatlVertex1/v2");
|
||||
assertEqual(actual[1]["UnitTestsAhuacatlVertex1/v2"][0]._id , "UnitTestsAhuacatlVertex1/v1");
|
||||
assertEqual(actual[2]["UnitTestsAhuacatlVertex1/v3"][0]._id , "UnitTestsAhuacatlVertex2/v8");
|
||||
|
||||
assertEqual(actual[3]["UnitTestsAhuacatlVertex2/v5"][0]._id , "UnitTestsAhuacatlVertex2/v6");
|
||||
|
||||
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v6"][0]._id , "UnitTestsAhuacatlVertex2/v5");
|
||||
assertEqual(actual[5]["UnitTestsAhuacatlVertex2/v8"][0]._id , "UnitTestsAhuacatlVertex1/v3");
|
||||
assertEqual(actual[0][v1][0]._id , v2);
|
||||
assertEqual(actual[1][v2][0]._id , v1);
|
||||
assertEqual(actual[2][v3][0]._id , v8);
|
||||
assertEqual(actual[3][v5][0]._id , v6);
|
||||
assertEqual(actual[4][v6][0]._id , v5);
|
||||
assertEqual(actual[5][v8][0]._id , v3);
|
||||
|
||||
actual = testGraph._amountCommonProperties({} , {}, {ignoreProperties : 'harald'});
|
||||
assertEqual(actual, [
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v1" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v2" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex1/v3" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v5" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v6" : 1
|
||||
},
|
||||
{
|
||||
"UnitTestsAhuacatlVertex2/v8" : 1
|
||||
}
|
||||
createKeyValueObject(v1, 1),
|
||||
createKeyValueObject(v2, 1),
|
||||
createKeyValueObject(v3, 1),
|
||||
createKeyValueObject(v5, 1),
|
||||
createKeyValueObject(v6, 1),
|
||||
createKeyValueObject(v8, 1)
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue