众所周知,在spark Graphx的求子图方法subgraph中,返回的子图有可能会包含孤立点,即该点无任何边:
算法源码如下所示:
override def subgraph( epred: EdgeTriplet[VD, ED] => Boolean = x => true, vpred: (VertexId, VD) => Boolean = (a, b) => true): Graph[VD, ED] = { vertices.cache() // Filter the vertices, reusing the partitioner and the index from t