I have the following graph:
// Vertices
val usersTest: RDD[(VertexId, (String))] = sc.parallelize(Array((1L, ("AAA")), (2L, ("BBB")), (3L, ("CCC"))))
// Edges
val relationshipsTest: RDD[Edge[Int]] = sc.parallelize(Array(Edge(1L, 3L, 1),Edge(1L, 3L, 1),Edge(1L, 2L, 3), Edge(2L, 1L, 1), Edge(2L, 1L, 2), Edge(2L, 3L, 1), Edge(3L, 2L, 2)))
val defaultUserTest = "Missing"
//Creating the Graph
val graphTest = Graph(usersTest, relationshipsTest, defaultUserTest)
Which produces the following output:
(graphTest.numEdges, graphTest.numVertices)
res: (Long, Long) = (7,3)
Now, when I try to use subgraph:
val validGraphTest = graphTest.subgraph(epred = e => e.attr > 2)
I obtain:
( validGraphTest.numEdges, validGraphTest.numVertices)
res: (Long, Long) = (1,3)
What I would like is to drop the unconnected vertices (i.e. in the example, since I have only one edge left, the desired output would be res:(Long, Long) = (1,2)
)
I have tried
val validCCGraphTest = validGraphTest.connectedComponents()
but ( validCCGraphTest.numEdges, validCCGraphTest.numVertices)
still produces res: (Long, Long) = (1,3)