I want to check out if a new graph(called A) is the sub-graph of other graph(called B). And i write a little demo for test, but failed! I run the demo just on spark-shell, spark version 1.6.1:
// Build the GraphB
val usersB = sc.parallelize(Array(
(3L, ("rxin", "student")),
(7L, ("jgonzal","postdoc")),
(5L, ("franklin", "prof")),
(2L, ("istoica", "prof"))
))
val relationshipsB = sc.parallelize(Array(
Edge(3L, 7L, "collab"),
Edge(5L, 3L, "advisor"),
Edge(2L, 5L, "colleague"),
Edge(5L, 7L, "pi")
))
val defaultUser = ("John Doe", "Missing")
val graphB = Graph(usersB, relationshipsB, defaultUser)
// Build the initial Graph A
val usersA = sc.parallelize(Array(
(3L, ("rxin", "student")),
(7L, ("jgonzal", "postdoc")),
(5L, ("franklin", "prof"))
))
val relationshipsA = sc.parallelize(Array(
Edge(3L, 7L, "collab"),
Edge(5L, 3L, "advisor")
))
val testGraphA = Graph(usersA, relationshipsA, defaultUser)
//do the mask
val maskResult = testGraphA.mask(graphB)
maskResult.edges.count
maskResult.vertices.count
In my understanding of API on spark website, mask funciton could get all the same edges and vertices. However, the result is vertices is correct only( maskResult.vertices.count = 3), the count of edges should be 2 but not(maskResult.edges.count = 0).