1
入力データJSON形式でのサイファー出力
MATCH (n) DETACH DELETE n;
CREATE (p:Provider {id:1, specialty:"Cardiology", pcp:0});
CREATE (p:Provider {id:2, specialty:"Internal Medicine", pcp:1});
CREATE (p:Provider {id:3, specialty:"Family Practice", pcp:1});
CREATE (p:Provider {id:4, specialty:"Radiology", pcp:0});
MATCH (p1:Provider {id:1}), (p2:Provider {id:2}) CREATE
(p1)-[:SHARED {mbrid:1}]->(p2),
(p1)-[:SHARED {mbrid:2}]->(p2),
(p1)-[:SHARED {mbrid:2}]->(p2),
(p1)-[:SHARED {mbrid:3}]->(p2);
MATCH (p1:Provider {id:2}), (p2:Provider {id:3}) CREATE
(p1)-[:SHARED {mbrid:4}]->(p2),
(p1)-[:SHARED {mbrid:5}]->(p2);
MATCH (p1:Provider {id:1}), (p2:Provider {id:3}) CREATE
(p1)-[:SHARED {mbrid:6}]->(p2);
MATCH (p1:Provider {id:1}), (p2:Provider {id:4}) CREATE
(p1)-[:SHARED {mbrid:9}]->(p2),
(p1)-[:SHARED {mbrid:10}]->(p2),
(p1)-[:SHARED {mbrid:11}]->(p2),
(p1)-[:SHARED {mbrid:12}]->(p2),
(p1)-[:SHARED {mbrid:12}]->(p2);
CREATE INDEX ON :Provider(id);
クエリ
MATCH (p1:Provider)-[s:SHARED]-(p2:Provider)
WHERE p1.id<p2.id and (p1.pcp=0 or (p1.pcp=1 and p2.pcp=0))
WITH p1, p2, count(distinct s.mbrid) as cnt
WHERE cnt>1
RETURN p1, p2, cnt;
出力
+------------------------------------------------------------------------------------------------------+
| p1 | p2 | cnt |
+------------------------------------------------------------------------------------------------------+
| Node[0]{id:1,specialty:"Cardiology",pcp:0} | Node[1]{pcp:1,id:2,specialty:"Internal Medicine"} | 3 |
| Node[0]{id:1,specialty:"Cardiology",pcp:0} | Node[3]{id:4,specialty:"Radiology",pcp:0} | 4 |
+------------------------------------------------------------------------------------------------------+
。 id 3のノードは出力にないので、下にリストされていないことを確認してください。また、出力ノードは0,1,2のインデックスを作成し、私はこれを作成する方法上の任意の入力/ポインタをいただければ幸いですリンク
{
"nodes" : [
{
"specialty" : "Cardiology",
"pcp" : 0
},
{
"specialty" : "Internal Medicine",
"pcp" : 1
},
{
"specialty" : "Radiology",
"pcp" : 0
}
],
"links" : [
{
"source" : 0,
"target" : 1,
"value" : 3
},
{
"source" : 0,
"target" : 2,
"value" : 4
}
]
}
に使用されています。