在Cypher我有查询:
MATCH (f:Friend)-[:friend_of]-(Friend)-[:friend_of]-(c:Friend)
WHERE c.name STARTS WITH "T"
RETURN f.name AS Friend1 , c2.name as Friend2
的另一个例子
MATCH (john {name: 'John'})-[:friend]->()-[:friend]->(fof)
RETURN john.name, fof.name
基本上它的剂量:此查询在返回'John'和找到的任何朋友之前找到一个名为'John'和'John'的朋友(虽然不是他的直接朋友)
这是Spark Graph X的示例:
// Create an RDD for the vertices
val users: RDD[(VertexId, (String, String))] =
sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),
(5L, ("franklin", "prof")), (2L, ("istoica", "prof")),
(4L, ("peter", "student"))))
// Create an RDD for edges
val relationships: RDD[Edge[String]] =
sc.parallelize(Array(Edge(3L, 7L, "friend_of"), Edge(5L, 3L, "friend_of"),
Edge(2L, 5L, "friend_of"), Edge(5L, 7L, "friend_of"),
Edge(4L, 0L, "friend_of"), Edge(5L, 0L, "friend_of")))
// Define a default user in case there are relationship with missing user
val defaultUser = ("John Doe", "Missing")
// Build the initial Graph
val graph = Graph(users, relationships, defaultUser)
// Where do we go, Where do we go now..?!
我看到的GraphX中的所有示例都是相同的概念Node->Rel->Node
。但如何做Node->Rel->Node->Rel->Node