Closed zzl221000 closed 4 years ago
Please be more specific - show some code and show the result you would like.
Thank you @joefagan for replying. I want the following return like expectation THere some vertex and Edge in agens like:
(c)-[ab]->(b)
(c)-[cd]->(d)
(b)-[bd]->(d)
(c)-[cm]->(m)
execute:
match (n:rlnode {rlid:'c'})-[e:knows*..3]-(m:rlnode) return n,e,m;
result:
n|e|m
-------
rlnode[3.260247]{"rlid":` "c"} [knows[4.331984][3.260247,3.260246]{"rel": "ab"}] rlnode[3.260246]{"rlid": "b"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331984][3.260247,3.260246]{"rel": "ab"},knows[4.331987][3.260246,3.260248]{"rel": "db"}] rlnode[3.260248]{"rlid": "d"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331984][3.260247,3.260246]{"rel": "ab"},knows[4.331987][3.260246,3.260248]{"rel": "db"},knows[4.331985][3.260247,3.260248]{"rel": "cd"}] rlnode[3.260247]{"rlid": "c"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331985][3.260247,3.260248]{"rel": "cd"}] rlnode[3.260248]{"rlid": "d"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331985][3.260247,3.260248]{"rel": "cd"},knows[4.331987][3.260246,3.260248]{"rel": "db"}] rlnode[3.260246]{"rlid": "b"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331985][3.260247,3.260248]{"rel": "cd"},knows[4.331987][3.260246,3.260248]{"rel": "db"},knows[4.331984][3.260247,3.260246]{"rel": "ab"}] rlnode[3.260247]{"rlid": `"c"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331986][3.260249,3.260247]{"rel": "cm"}] rlnode[3.260249]{"rlid": `"m"}
expectation:
rlnode[3.260247]{"rlid":` "c"} [knows[4.331984][3.260247,3.260246]{"rel": "ab"}] rlnode[3.260246]{"rlid": "b"}
rlnode[3.260247]{"rlid": "d"} knows[4.331987][3.260246,3.260248]{"rel": "db"}] rlnode[3.260248]{"rlid": "d"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331985][3.260247,3.260248]{"rel": "cd"}] rlnode[3.260248]{"rlid": "d"}
rlnode[3.260247]{"rlid": "c"} [knows[4.331986][3.260249,3.260247]{"rel": "cm"}] rlnode[3.260249]{"rlid": `"m"}
Don't use '*..3'. The variable length expression matches v-e-v, v-e-v-e-v, and v-e-v-e-v-e-v.
Hi First use ()-[]->() or ()<-[]-() to find relationship in a particular direction. If you want to see exactly 2 hops away do match p = ()-[ :elabel 2 ]->() return p; To see only the end nodes match (x)-[ :elabel 2 ]->(y) return *; I still don't know exactly what you want to see. Feel free to describe it once more.
Don't use '*..3'. The variable length expression matches v-e-v, v-e-v-e-v, and v-e-v-e-v-e-v.
I just want to find out the 3 degree association of C. @jrgemignani
Hi First use ()-[]->() or ()<-[]-() to find relationship in a particular direction. If you want to see exactly 2 hops away do match p = ()-[ :elabel 2 ]->() return p; To see only the end nodes match (x)-[ :elabel 2 ]->(y) return *; I still don't know exactly what you want to see. Feel free to describe it once more.
I just want to find out the 3 degree association of C,but nothing on the relationship's direction @joefagan
Send me some code and 'exactlty' what you would like to see and I will do it.
I want to implement a graph display of a social network. The variable length expression is nice,but result is v-e-v ,v-e-v-e-v,v-e-v-e-v-e-v I just need v-e-v pair. As follows, temporarily implement this function by recursion. @joefagan
public void three(String id,Set<Vertex> nodes,Set<Edge> edges,int degree,boolean init) throws SQLException {
if (degree>3){return;}
try (Connection connection = dataSource.getConnection();
PreparedStatement pstmt = connection.prepareStatement(
"match (n:rlnode {rlid:?})-[e:knows]-(m:rlnode) return n,e,m;"
)) {
pstmt.setString(1, id);
try (ResultSet rs = pstmt.executeQuery()) {
while (rs.next()) {
if (init){
nodes.add((Vertex) rs.getObject(1));
init=false;
}
edges.add((Edge) rs.getObject(2));
Vertex object = (Vertex) rs.getObject(3);
nodes.add(object);
String rlid = object.getProperties().getString("rlid");
three(rlid, nodes, edges, ++degree, init);
}
}
}
}
Jim, If you like - let's do a call. If you can use Google hangouts I can share screen and show you what you need to do (when I really understand what you want). If so drop me a note to Joe.Fagan@bitnine.net I'm the pre-sales director EMEA for AgensGraph. What timezone are you in? I'm in UK so BST timezone. Thanks Joe
` (vertex a)-[]-(vertex b)
(vertex b)-[]-(vertex c)
match (a)-[*1..2]-()
result:
(vertex a)-[]-(vertex b)
(vertex a)-[]-(vertex b)-[]-(vertex c)
` Is there a way to return only the data format vertex-edge-vertex?