Skip to content

Instantly share code, notes, and snippets.

@mzsima
Last active May 12, 2020 14:46
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/ae155a5403c1c366161c796ebce0f34f to your computer and use it in GitHub Desktop.
Save mzsima/ae155a5403c1c366161c796ebce0f34f to your computer and use it in GitHub Desktop.
D2C 太郎は無印の商品を直販かファミマで購入する

image

snapshot

gremlin code

schema.vertexLabel("Consumer").
       ifNotExists().
       partitionBy("name", Text).
       create();

schema.vertexLabel("Manufacture").
       ifNotExists().
       partitionBy("name", Text).
       create();
       
schema.vertexLabel("Shop").
       ifNotExists().
       partitionBy("name", Text).
       create();

schema.edgeLabel('direct').
  ifNotExists().
  from('Manufacture').to('Consumer').
  create()
       

schema.edgeLabel('sells').
  ifNotExists().
  from('Shop').to('Consumer').
  create()
  

schema.edgeLabel('distributes').
  ifNotExists().
  from('Manufacture').to('Shop').
  create()
  

taro = g.addV("Consumer").
        property("name", "Taro").
        next();
        
muji = g.addV("Manufacture").
        property("name", "MUJI").
        next();
        
famima = g.addV("Shop").
        property("name", "Famima").
        next();
        
g.addE("direct").
    from(muji).
    to(taro).
    next();

g.addE("distributes").
    from(muji).
    to(famima).
    next();
    
g.addE("sells").
    from(famima).
    to(taro).
    next();

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