removing vertices with no edges in graphx spark

656 views Asked by At

I was wondering if somebody could help, I'm having a problem with a function written for graphx in spark which keeps giving error messages if I have vertices with no edges.

When joining edges and vertices together

val graph = Graph(vertices, edges)

is there a simple way to skip over vertices which do not have any corresponding edges? or is there a way of subgraphing for this? Currently if I use subgraph for say an edge attribute, it preserves the vertices.

Many thanks for your help

1

There are 1 answers

0
Zhu Coding On

val graph = Graph(vertices, edges) <---this one got an error? maybe you should give the type of VD and Ed, like val graph:Graph[Int, Int] = Graph(vertices, edges).

In fact, vextice with no edges is ok. I have tried with 10 vertices and two of which has no edges.