Dse Graph - 获取两个顶点之间的所有边

时间:2017-01-13 16:05:59

标签: datastax-enterprise gremlin datastax-java-driver tinkerpop datastax-enterprise-graph

我正在使用DSE graph 5.X

假设我有两个顶点,顶点A和顶点B。

Dse文档说明了单独获取顶点和边缘。

但我要找的是获取特定label的所有顶点或两个顶点之间的所有边。

如何在Java代码中检索顶点A和顶点B之间的所有边?

E.g List<Edge> edges = graph.getEdges(fromVertex, toVertex);

谢谢你......!

2 个答案:

答案 0 :(得分:3)

一般来说,gremlin配方页面适合像http://tinkerpop.apache.org/docs/current/recipes/#between-vertices

这样的东西

如果您知道顶点ID,那么您可以使用

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
        PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html">
<h:head>
    <title>index 2</title>
</h:head>
<h:body>
    <h:form>
        Whats your Name?<br/>
        <h:inputText value="#(user.name)"/>
        <h:commandButton action="greet" value="GO"/>
    </h:form>
</h:body>
</html>

答案 1 :(得分:2)

嗨,让我给你一个dse图形查询,它将计算两个顶点之间的边数,然后你可以在java中执行或运行相同的查询: -

g.V().hasLabel('users').has('userId','8e4b334a-388e-4623-91d6-fad7570e3129').outE('hasA').as('e').inV().hasLabel('mobileNo').select('e').count()

找到具有标签&#39; USERS&#39;的顶点。特别是Vertex有一些USER_ID,Vertex连接为&#39; MOBILE_NO&#39;

您可以跳过user_id部分查询,并可以在特定标签的任意两个顶点之间进行计数。