Search code examples
scalaapache-sparkspark-graphx

graphX cannot graph multiple Edges and Vertices?


my vertice type is:

org.apache.spark.rdd.RDD[((Long, String), (Long, String), (Long, String))]

my edge type is:

org.apache.spark.rdd.RDD[(org.apache.spark.graphx.Edge[String],org.apache.spark.graphx.Edge[String])]

When I tried to Graph(vertices, edges).

It's saying:

<console>:47: error: type mismatch;
 found   : org.apache.spark.rdd.RDD[((Long, String), (Long, String), (Long, String))]
 required: org.apache.spark.rdd.RDD[(org.apache.spark.graphx.VertexId, ?)]

<console>:47: error: type mismatch;
 found   : org.apache.spark.rdd.RDD[(org.apache.spark.graphx.Edge[String], org.apache.spark.graphx.Edge[String])]
 required: org.apache.spark.rdd.RDD[org.apache.spark.graphx.Edge[?]]

(Long String) is tuple2.


Solution

  • I think you have to correct both your vertex and edge rdd.

    vertex rdd it is a rdd[(VertexId, vertexValueType)]

    so you have to change your vertex rdd to:

    org.apache.spark.rdd.RDD[(VertexId, ((Long, String), (Long, String), (Long, String)))]
    

    and edge rdd it is a rdd[Edge[edgeValueType]] so indeed it should be like this:

    org.apache.spark.rdd.RDD[org.apache.spark.graphx.Edge[String]]
    

    Maybe you can post a code where you actually create this rdds?