Skip to content

Instantly share code, notes, and snippets.

@mzsima
Last active May 10, 2020 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mzsima/b5f274a11220fe77385809d2ac4ae140 to your computer and use it in GitHub Desktop.
Save mzsima/b5f274a11220fe77385809d2ac4ae140 to your computer and use it in GitHub Desktop.
a circle of friends

image

snapshot

gremlin

schema.vertexLabel('User').
       ifNotExists().
       partitionBy('uid', Text).
       property('name', Text).
       create();
       
schema.edgeLabel('friend').
       ifNotExists().
       from('User').
       to('User').
       create();
       
user0 = g.addV("User").
        property("uid", "user0").
        property("name", "Taro").
        next();
previous = user0

for(i=1; i<5; i++) {
    user = g.addV("User").
        property("uid", "user" + i).
        property("name", "Taro").
        next();
    
    g.addE('friend').
      from(previous).
      to(user).
      next();
      
    previous = user
}

g.addE('friend').
  from(previous).
  to(user0).
  next();


dev.V()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment