使用 sigma.js 函数之一连接到 neo4j
Connection to neo4j using one of the sigma.js function
我正在尝试连接 sigma.js 和 neo4j。对于连接,我想使用此代码:
sigma.neo4j.cypher_parse = function(result) {
var graph = { nodes: [], edges: [] },
nodesMap = {},
edgesMap = {},
key; ...
但我不知道变量结果的确切含义。
你试试cypher插件的内部功能,不错
看看方法的JSdoc:
/**
* This function parse a neo4j cypher query result, and transform it into
* a sigma graph object.
*
* @param {object} result The server response of a cypher query.
*
* @return A graph object
*/
所以结果是neo4j服务器的结果。您可以查看 neo4j 事务端点:http://neo4j.com/docs/stable/rest-api-transactional.html#rest-api-begin-and-commit-a-transaction-in-one-request
所以结果是一个像这样的 json 对象 :
{
"results" : [ {
"columns" : [ "id(n)" ],
"data" : [ {
"row" : [ 15 ]
} ]
} ],
"errors" : [ ]
}
但为什么您不想像这样使用具有主要功能的插件:
mySigmaInstance = new sigma({
graph: {
nodes: [],
edges: []
},
container: 'graph-container'
});
sigma.parsers.cypher(
{ url: 'http://localhost:7474', user:'neo4j', password:'admin' },
'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
mySigmaInstance,
function() {
// Put here your custom code
// It's the callback function
mySigmaInstance.refresh();
}
);
我正在尝试连接 sigma.js 和 neo4j。对于连接,我想使用此代码:
sigma.neo4j.cypher_parse = function(result) {
var graph = { nodes: [], edges: [] },
nodesMap = {},
edgesMap = {},
key; ...
但我不知道变量结果的确切含义。
你试试cypher插件的内部功能,不错
看看方法的JSdoc:
/**
* This function parse a neo4j cypher query result, and transform it into
* a sigma graph object.
*
* @param {object} result The server response of a cypher query.
*
* @return A graph object
*/
所以结果是neo4j服务器的结果。您可以查看 neo4j 事务端点:http://neo4j.com/docs/stable/rest-api-transactional.html#rest-api-begin-and-commit-a-transaction-in-one-request
所以结果是一个像这样的 json 对象 :
{
"results" : [ {
"columns" : [ "id(n)" ],
"data" : [ {
"row" : [ 15 ]
} ]
} ],
"errors" : [ ]
}
但为什么您不想像这样使用具有主要功能的插件:
mySigmaInstance = new sigma({
graph: {
nodes: [],
edges: []
},
container: 'graph-container'
});
sigma.parsers.cypher(
{ url: 'http://localhost:7474', user:'neo4j', password:'admin' },
'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
mySigmaInstance,
function() {
// Put here your custom code
// It's the callback function
mySigmaInstance.refresh();
}
);