0
votes

I have a vertex label "group" and a group can have multiple "categories". For example, a group named "food" can have multiple categories like "Seafood, Chinese, Indian" which are connected by an edge labelled "label1". Now, a category can have further categories, like "Seafood" can have "fish, prawns" and so on. the depth is arbitrary and these all further categories are connected by edge labelled "label2".

food --label1--> seafood --label2--> fish --label2--> jellyfish --label2--> so on
                                          --label2--> starfish
                         --label2--> prawns
                         --label2--> crab

     --label1--> Indian  
     --label1--> Chinese 

I want to recursively traverse all the vertices and get the data. I hope you understood the question. Please help me out.

1
also please suggest if there is any other better way to store such data, like a menu and further sub-menus and so on.Vipul Sharma

1 Answers

2
votes

It's as easy as:

g.V(food).out("label1").
  emit().
    repeat(out("label2"))