Gremlin, including vertices with zero edges

DrAhmedJava

let's say you have the following relationship:

Author-----wrote---->Article

and you want to prepare a report about each author and how many articles he has wrote and the date of his last article, the proplem appears when there are authors who wrote no articles, they will be dropped when you pass the 'wrote' pipe and i want to include them with '0' in 'count' column and 'N/A' in 'date' column, so my quesion is how to solve this problem ?

stephen mallette

I assume that you are still working with TinkerPop 2.x given your usage of OrientDB so I will answer in that fashion. You need to do something like:

gremlin> g = new TinkerGraph()                        
==>tinkergraph[vertices:0 edges:0]
gremlin> bill = g.addVertex([author:'bill',type:'author'])
==>v[0]
gremlin> amy = g.addVertex([author:'amy',type:'author'])  
==>v[1]
gremlin> book1 = g.addVertex([book:1,type:'book'])        
==>v[2]
gremlin> book2 = g.addVertex([book:2,type:'book'])        
==>v[3]
gremlin> bill.addEdge('wrote',book1)                      
==>e[4][0-wrote->2]
gremlin> bill.addEdge('wrote',book2)
==>e[5][0-wrote->3]
gremlin> g.V.has('type','author').transform{[it, it.outE('wrote').count()]}
==>[v[0], 2]
==>[v[1], 0]

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Gremlin, including vertices with zero edges

From Dev

Gremlin: can't sort edges and return vertices

From Dev

filter vertices on number of outgoing edges in gremlin titan in java

From Dev

Gremlin get all incoming and outgoing vertex, including their edges and directions

From Dev

Cayley: How do insert vertices and edges into graph using Cayley-Gremlin code?

From Dev

Labels,vertices and edges TitanDB

From Dev

Randomly generate edges and vertices

From Dev

Labels,vertices and edges TitanDB

From Dev

Duplicate Vertices and Edges in OrientDB

From Dev

Gremlin : Add multiple vertices in single gremlin query?

From Dev

Boost Graph with custom vertices and edges

From Dev

igraph: plot only edges, no vertices

From Dev

BFS on graph vertices and edges as neighbors

From Dev

How to select random vertices in Gremlin

From Dev

How to select random vertices in Gremlin

From Dev

Including edges in this pnpoly algorithm

From Dev

TinkerPop: Gremlin revisiting visited edges

From Dev

How to find the number of edges or vertices between any two vertices of a tree?

From Dev

Finding Edges and Vertices Within Heightmap Array

From Dev

Titan graph: Finding vertices without outgoing edges

From Dev

intersect graphs sharing a percentage of edges and vertices

From Dev

How to choose between Links and Edges to connect vertices?

From Dev

OrientDB select unique Vertices from multiple Edges

From Dev

Removing minimum no of edges to disconnect two vertices in a graph

From Dev

Removing minimum no of edges to disconnect two vertices in a graph

From Dev

intersect graphs sharing a percentage of edges and vertices

From Dev

copying edges with adjacent vertices and their properties using BOOST

From Dev

Finding Edges and Vertices Within Heightmap Array

From Dev

Dijkstra with parallel edges between two Vertices

Related Related

  1. 1

    Gremlin, including vertices with zero edges

  2. 2

    Gremlin: can't sort edges and return vertices

  3. 3

    filter vertices on number of outgoing edges in gremlin titan in java

  4. 4

    Gremlin get all incoming and outgoing vertex, including their edges and directions

  5. 5

    Cayley: How do insert vertices and edges into graph using Cayley-Gremlin code?

  6. 6

    Labels,vertices and edges TitanDB

  7. 7

    Randomly generate edges and vertices

  8. 8

    Labels,vertices and edges TitanDB

  9. 9

    Duplicate Vertices and Edges in OrientDB

  10. 10

    Gremlin : Add multiple vertices in single gremlin query?

  11. 11

    Boost Graph with custom vertices and edges

  12. 12

    igraph: plot only edges, no vertices

  13. 13

    BFS on graph vertices and edges as neighbors

  14. 14

    How to select random vertices in Gremlin

  15. 15

    How to select random vertices in Gremlin

  16. 16

    Including edges in this pnpoly algorithm

  17. 17

    TinkerPop: Gremlin revisiting visited edges

  18. 18

    How to find the number of edges or vertices between any two vertices of a tree?

  19. 19

    Finding Edges and Vertices Within Heightmap Array

  20. 20

    Titan graph: Finding vertices without outgoing edges

  21. 21

    intersect graphs sharing a percentage of edges and vertices

  22. 22

    How to choose between Links and Edges to connect vertices?

  23. 23

    OrientDB select unique Vertices from multiple Edges

  24. 24

    Removing minimum no of edges to disconnect two vertices in a graph

  25. 25

    Removing minimum no of edges to disconnect two vertices in a graph

  26. 26

    intersect graphs sharing a percentage of edges and vertices

  27. 27

    copying edges with adjacent vertices and their properties using BOOST

  28. 28

    Finding Edges and Vertices Within Heightmap Array

  29. 29

    Dijkstra with parallel edges between two Vertices

HotTag

Archive