Creat graph from specific vertices graphx spark

Using subgraph worked :

This function should be used when you want to filter out of a graph either edges or vertices.

Here is the code I used for this particular problem :

val graph = Graph.apply(verticesTrain.map(vertex => (vertex,1.0)),edges.map{case(s,d)=>Edge(s,d,1.0)})

val filtered = graph.subgraph(vpred = (vid,vd)=>vd!=null.asInstanceOf[Double])

filtered.vertices.count()
Out: Long
44906

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top