How to get the out-degree/the in-degree of a vertex with a given name in Nebula Graph?

40 Views Asked by At

I have created a set of data in Nebula Graph Database, I want to know how to get the out-degree and in-degree of a vertex with a given name.

(root@nebula) [basketballplayer]> match (v) return v limit 10
+-----------------------------------------------------------+
| v                                                         |
+-----------------------------------------------------------+
| ("player102" :player{age: 33, name: "LaMarcus Aldridge"}) |
| ("player106" :player{age: 25, name: "Kyle Anderson"})     |
| ("player115" :player{age: 40, name: "Kobe Bryant"})       |
| ("player129" :player{age: 37, name: "Dwyane Wade"})       |
| ("player138" :player{age: 38, name: "Paul Gasol"})        |
| ("team209" :team{name: "Timberwolves"})                   |
| ("team225" :team{name: "Bucks"})                          |
| ("team226" :team{name: "Magic"})                          |
| ("player108" :player{age: 36, name: "Boris Diaw"})        |
| ("player122" :player{age: 30, name: "DeAndre Jordan"})    
1

There are 1 best solutions below

0
On

The out-degree of a vertex refers to the number of edges starting from that vertex, while the in-degree refers to the number of edges pointing to that vertex.

nebula > MATCH (s)-[e]->() WHERE id(s) == "given" RETURN count(e); #Out-degree
nebula > MATCH (s)<-[e]-() WHERE id(s) == "given" RETURN count(e); #In-degree

This is a very slow operation to get the out/in degree since no accelaration can be applied (no indices or caches). It also could be out-of-memory when hitting a supper-node.