janusgraph在不同的时间创造相同的garph

时间:2017-11-29 12:51:00

标签: janusgraph

在这种情况下,首先,我打开一个janusgraph,创建一些顶点和边  然后,我打开了相同的janusgraph,创建了一些顶点和边缘 并关闭它。

毕竟,我想找到一个顶点到另一个顶点的路径,我发现两个顶点不在一个路径中,因为它们是在不同的时间创建的;但是,如果我一起创建它们,路径是正确的。

以下是一些创建代码:

val grap = JanusGraphFactory.open("d:\\janusgraph\\janusgraph-hbase.properties")
     val mgmt = grap.openManagement()

     mgmt.makePropertyKey("value").dataType(classOf[String]).make()

     mgmt.makeEdgeLabel("deviceid").make()

     mgmt.makeVertexLabel("phone").make()


    val tx = grap.newTransaction()

    val phone1 = tx.addVertex(T.label, "phone", "value", "13700000001")
    val phone2 = tx.addVertex(T.label, "phone", "value", "13700000002")
    val phone3 = tx.addVertex(T.label, "phone", "value", "13700000003")
    val phone4 = tx.addVertex(T.label, "phone", "value", "13700000004")
    val phone5 = tx.addVertex(T.label, "phone", "value", "13700000005")
    val dev1 = tx.addVertex(T.label, "dev", "value", "dev1")
    val dev2 = tx.addVertex(T.label, "dev", "value", "dev2")
    val dev3 = tx.addVertex(T.label, "dev", "value", "dev3")*/


    phone1.addEdge("phone-dev", dev1, "value", "13700000001_dev1")
    phone2.addEdge("phone-dev", dev1, "value", "13700000002_dev1")
    phone2.addEdge("phone-dev", dev2, "value", "13700000002_dev2")

    phone3.addEdge("phone-dev", dev2, "value", "13700000003_dev2")

    phone4.addEdge("phone-dev", dev2, "value", "13700000004_dev2")
    phone4.addEdge("phone-dev", dev3, "value", "13700000004_dev3")


    tx.commit()
    tx.close()

这里有寻找代码:

  val graph = JanusGraphFactory.open("d:\\janusgraph\\janusgraph-hbase.properties")
    //val graph = JanusGraphFactory.open(configuration)
    val g = graph.traversal()
    val result2 = g.V().hasLabel("phone").repeat(both().simplePath()).until(bothE().count().is(1)).path().by("value").toSet
    //val result = g.V().hasLabel("phone").repeat(both().simplePath()).until(bothE().count().is(1)).path().by

    val it = result2.iterator()
    while (it.hasNext) {
        println("path=>" + it.next())
    }
    System.exit(1)

0 个答案:

没有答案