0

How can i find FoFoF in Spark GraphX ?

In Cypher i have query:

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

Another example from here

MATCH (john {name: 'John'})-[:friend]->()-[:friend]->(fof)
RETURN john.name, fof.name

Basicly what it dose: this query finds a user called 'John' and 'John’s' friends (though not his direct friends) before returning both 'John' and any friends-of-friends that are found

  • What the alternative implmentation of Spark GraphX ?
  • How can i implement this query as Spark GraphX?

This is example from 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..?!

All the examples in the GraphX that i saw, are in same concept Node->Rel->Node. but how to do Node->Rel->Node->Rel->Node

Community
  • 1
  • 1
Yehuda
  • 457
  • 2
  • 6
  • 16
  • can you elaborate what your `Cypher` query exactly does? – mtoto May 29 '17 at 11:57
  • Basically what it dose: my query returns all Friends of Friends that their name starts with T. – Yehuda May 29 '17 at 12:07
  • dupe https://stackoverflow.com/questions/37417469/graphx-retrieving-all-nodes-from-a-path – eliasah May 29 '17 at 12:16
  • Sorry, It's not duplicated, in [your link](https://stackoverflow.com/questions/37417469/graphx-retrieving-all-nodes-from-a-path) it only two steps FoF, i need implementation of 3 steps FoFoF. The difference is that, all the examples in the graphx is in same concept Node->Rel->Node. but how to do Node->Rel->Node->Rel->Node – Yehuda May 29 '17 at 12:31
  • [GraphFrames](https://databricks.com/blog/2016/03/16/on-time-flight-performance-with-graphframes-for-apache-spark.html) have a similar feature called motif finding. – mtoto May 29 '17 at 13:07
  • motif finding still has a lot of missing like [this](https://stackoverflow.com/questions/32503350/return-my-friends-and-friends-of-friends-using-neo4js-cypher), or [this](https://stackoverflow.com/questions/9952022/how-to-get-friends-of-friends-that-have-the-same-interest) – Yehuda May 29 '17 at 21:16

0 Answers0