0
votes

With reference To link

https://github.com/tinkerpop/blueprints/wiki/GraphSON-Reader-and-Writer-Library

How to label the vertices in the json file which will result in speeding up graph traversals. I am using titan graph db . So GRAPHSON will be used for converting json into graph instance and also using gremlin query language . And thus to speed up the retrieval of vertices i need to label these vertices to categorise . How Can i add label ??

{
"mode":"EXTENDED",
"vertices": [
    {
        "name": {
            "type": "string",
            "value": "lop"
        },
        "lang": {
            "type": "string",
            "value": "java"
        },
        "_id": "3",
        "_type": "vertex"
    },
    {
        "name": {
            "type": "string",
            "value": "vadas"
        },
        "age": {
            "type": "integer",
            "value": 27
        },
        "_id": "2",
        "_type": "vertex"
    },
    {
        "name": {
            "type": "string",
            "value": "marko"
        },
        "age": {
            "type": "integer",
            "value": 29
        },
        "_id": "1",
        "_type": "vertex"
    },
    {
        "name": {
            "type": "string",
            "value": "peter"
        },
        "age": {
            "type": "integer",
            "value": 35
        },
        "_id": "6",
        "_type": "vertex"
    },
    {
        "name": {
            "type": "string",
            "value": "ripple"
        },
        "lang": {
            "type": "string",
            "value": "java"
        },
        "_id": "5",
        "_type": "vertex"
    },
    {
        "name": {
            "type": "string",
            "value": "josh"
        },
        "age": {
            "type": "integer",
            "value": 32
        },
        "_id": "4",
        "_type": "vertex"
    }
],
"edges": [
    {
        "weight": {
            "type": "float",
            "value": 1
        },
        "_id": "10",
        "_type": "edge",
        "_outV": "4",
        "_inV": "5",
        "_label": "created"
    },
    {
        "weight": {
            "type": "float",
            "value": 0.5
        },
        "_id": "7",
        "_type": "edge",
        "_outV": "1",
        "_inV": "2",
        "_label": "knows"
    },
    {
        "weight": {
            "type": "float",
            "value": 0.4000000059604645
        },
        "_id": "9",
        "_type": "edge",
        "_outV": "1",
        "_inV": "3",
        "_label": "created"
    },
    {
        "weight": {
            "type": "float",
            "value": 1
        },
        "_id": "8",
        "_type": "edge",
        "_outV": "1",
        "_inV": "4",
        "_label": "knows"
    },
    {
        "weight": {
            "type": "float",
            "value": 0.4000000059604645
        },
        "_id": "11",
        "_type": "edge",
        "_outV": "4",
        "_inV": "3",
        "_label": "created"
    },
    {
        "weight": {
            "type": "float",
            "value": 0.20000000298023224
        },
        "_id": "12",
        "_type": "edge",
        "_outV": "6",
        "_inV": "3",
        "_label": "created"
    }
]

}

1

1 Answers

0
votes

TinkerPop 2.x did not have native support for vertex labels and thus, GraphSON 2.x didn't support it either. TinkerPop 3.x (and thus Titan 1.0) have this support:

http://tinkerpop.incubator.apache.org/docs/3.0.1-incubating/#graphson-reader-writer

You'd either need to upgrade to Titan 1.0/TP3 or write a custom GraphSON processor using the Titan API in earlier versions of Titan/TP2.