JanusGraph教程
作者: 时海
JanusGraph写数据

1、JanusGraph 写顶点或边数据如下:

import org.apache.tinkerpop.gremlin.structure.Edge;
import org.apache.tinkerpop.gremlin.structure.Vertex;
import org.janusgraph.core.JanusGraph;
import org.janusgraph.core.JanusGraphFactory;

public class Test {
    public static void main(String[] args) {

        JanusGraph graph = JanusGraphFactory.open("conf/janusgraph-cassandra-es.properties");

        //创建顶点
        Vertex v1 = graph.addVertex("USER");
        v1.property("uid", "100");
        v1.property("name", "张三");
        v1.property("age", 23);

        Vertex v2 = graph.addVertex("PHONE");
        v2.property("phone", "13811111111");

        //创建边
        Edge e12 = v1.addEdge("USER_PHONE", v2);
        e12.property("create_time", "2018-08-08");

        graph.tx().commit();

        graph.close();

    }
}


欢迎加:知识图谱QQ交流群:829449428

标签: janusgraph、v1、property、graph、phone
一个创业中的苦逼程序员
  • 回复
隐藏