title: How to filter out null vertices from a graph
body: <p>Suppose my graph vertices are having null in their vertices, is there a way in subgraph to filter them out.</p>
  
  <pre><code>import org.apache.spark.rdd.RDD
  import org.apache.spark._
  import org.apache.spark.graphx._
  
  
  
  // Create an RDD for the vertices
  val users: RDD[(VertexId, (String, String))] =
    sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),
                         (5L, ("franklin", "prof")), (2L, ("istoica", "prof")),
                         (4L, null)))
  
  // Create an RDD for edges
  val relationships: RDD[Edge[String]] =
    sc.parallelize(Array(Edge(3L, 7L, "collab"),    Edge(5L, 3L, "advisor"),
                         Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi"),
                         Edge(4L, 0L, "student"),   Edge(5L, 0L, "colleague")))
  
  // Define a default user in case there are relationship with missing user
  val defaultUser = ("John Doe", "Missing")
  
  //val defaultUser = null
  
  // Build the initial Graph
  val graph = Graph(users, relationships, defaultUser)
  
  
  graph.triplets.collect.foreach(println)
  </code></pre>
  
  <p>When i try this</p>
  
  <pre><code>val validGraph = graph.subgraph(vpred = (id, attr) =&gt; (id,attr._1) != null)
  
  validGraph.triplets.collect.foreach(println)
  </code></pre>
  
  <p>I get a null pointer exception. I can do mapTriplets.filter like this</p>
  
  <pre><code>graph.triplets.filter(triplet =&gt; triplet.srcAttr != null)
  </code></pre>
  
  <p>but the problem is that i get an EdgeTriplet as output. After this i need to use a pregel call.</p>