Skip to content

Instantly share code, notes, and snippets.

@mzsima
Last active May 30, 2020 15:15
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/bb6997f31f7b932400ac2d391dc923f1 to your computer and use it in GitHub Desktop.
Save mzsima/bb6997f31f7b932400ac2d391dc923f1 to your computer and use it in GitHub Desktop.
ひらがな、あ行

image

snapshot

code gremlin

hiragana = "あいうえおかきくけこさしすせそたちつてとなにぬねの"


schema.vertexLabel("Letter").ifNotExists().partitionBy("id", Text).create();
schema.edgeLabel('row').ifNotExists().from('Letter').to('Letter').create()
schema.edgeLabel('col').ifNotExists().from('Letter').to('Letter').create()

List<Vertex> arr = new ArrayList<Vertex>();

for(i=0; i<25; i++){
    arr.add(g.addV("Letter").property("id", String.valueOf(hiragana.charAt(i))).next());
}

for(i=0; i<5; i++){
    from = arr.get(i)
    for (j=1; j<5; j++) {
        to = arr.get(i + j * 5)
        g.addE("col").from(from).to(to).next();
    }
}

for(i=0; i<5; i++){
    from = arr.get(i * 5)
    for (j=1; j<5; j++) {
        to = arr.get(i * 5 + j)
        g.addE("row").from(from).to(to).next();
    }
}

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