Use web framework for Django + py2neo, steps of implementation are as follows:
1. Use py2neo find out the relationship between the two companies , there is only 1 layer and 2 layer relations, are as follows:
MATCH p=(n3: {name: "Harbin bank co., LTD."}) & lt; - [3] rel_tmp * 1.. - & gt; (n4 interchange: {name: "prolong life in harmony hing village bank limited liability company"}) with nodes (p) as nn, rels (p) as rr match (n1) - (rel) - & gt; (n2) where n1 in nn and n2 in nn and rel rr return in n1, rel, n2
PS: why do you want to write of cypher, behind problems will be mentioned,
2. Send the results to the front, use js. According to the VIS js transformed data format specification, get nodes and edges,
var data=[https://bbs.csdn.net/topics/];
Var links=[];
//structure show data
//var maxDisPlayNode=15;
Var maxDisPlayNode=100;
Var id=0;
For (var I=0; Id & lt; MaxDisPlayNode& & I//get node1
Node1={};
Node1=searchResult [' label '] [I] [' n1] [' name '];
If (' url 'in searchResult [I] [' n1]) {
Node1 [' group ']=1;
}
The else {
Node1 [' group ']=2;
}
Var flag=1;
RelationTarget=id. The toString ();
For (var j=0; JIf (data [j] [' label ']===node1 [' label ']) {
Flag=0;
RelationTarget=data [j] [' id '];
Break;
}
}
Node1 [' id ']=relationTarget;
If (flag===1) {
Id++;
Data. Push (node1);
}
//to get 2
2={};
2 [' label ']=searchResult [I] [' n2] [' name '];
If (' url 'in searchResult [I] [' n']) {
2 [' group ']=1;
}
The else {
2 [' group ']=2;
}
Flag=1;
RelationTarget=id. The toString ();
For (var j=0; JIf (data [j] [' label ']===2 [' label ']) {
Flag=0;
RelationTarget=data [j] [' id '];
Break;
}
}
2 [' id ']=relationTarget;
If (flag===1) {
Id++;
Data. Push (2);
}
//get a function
Base={}
Base [' from ']=node1 [' id '].
Base [' to ']=2 [' id '].
Base [' group ']=0;
Flag=1;
For (var j=0; JIf (links [j] [' from ']==base [' from '] & amp; & The links [j] [' to ']==base [' target ']) {
The links [j] [' label ']=links [j] [' label '] + searchResult [I] [' rel '] [' type '].
Flag=0;
Break;
}
}
If (flag===1) {
Base [' label ']=searchResult [I] [' rel '] [' base '];
//function [' symbolSize]=10;
The links. Push (base);
}
}
3. Calling vis. Js to display,
var network=new vis.Net work (container, data1, options);
:
Vis. Js requirement for incoming data format of nodes and edges, node1 - [edge] - & gt; 2, that is, a pair of relationship shows two dots and a line, which requires the secondary data returned by the also want to meet this format, which is why the cypher in step 1 above to receive with with a match on the results of a query, to check the reason again, actually directly with the first match the query, return p already can query all the relations between the two companies, but the format does not meet the vis, js,
But do this problem comes, with after receiving a query result, has carried on the full table scan, causing the query performance is greatly reduced,
Direct query, return p value, has been able to query the relationship between, but the return format does not meet the vis, js,
Use with, again query, in order to meet the vis. Js data format, but the efficiency is too low, (see below)
In order to meet the demand, the main problem is query efficiency and data format issues, solve any question all can meet the demand, but the research for a long time, didn't find the right method, also please great god guide, thank you,
CodePudding user response:
There is no reply,,,CodePudding user response:
After another wall again,,,,,,,