如何在Spark / Scala Graphx中转换为VertexId?

时间:2016-09-19 12:11:42

标签: scala apache-spark spark-graphx

我正在尝试使用Scala在Apache Spark Graphx中创建一个图形。到目前为止我的代码是:

MessageBodyWriter

我收到以下错误:

    import org.apache.spark._
    import org.apache.spark.graphx._

    case class EdgesCl(Source:Long, Destination:Long, SourceLayer:Long, DestLayer:Long, Weight:Int = 1)

    object actual
    {

      def parseEdgesCl(str: String): EdgesCl =
      {
        val line = str.split(",")
        EdgesCl(line(0).toLong, line(1).toLong, line(2).toLong, line(3).toLong)
      }

      def main(args:Array[String]) {
        val conf = new SparkConf().setMaster("local").setAppName("SparkCommunityDetection")
        val sc = new SparkContext(conf)

        //Create RDD with Network data
        val textRDD = sc.textFile("/home/input_Files/test_net.csv")

        val EdgesClRDD = textRDD.map(parseEdgesCl).cache()

        val nodes = EdgesClRDD.map(node => (node.Source, node.SourceLayer)).distinct
        nodes.take(1)

        val edges_lines = EdgesClRDD.map(edge => ((edge.Source, edge.Destination), edge.SourceLayer, edge.DestLayer))

        // Defining a default vertex called nowhere
        val noedge = "noedge"

        val edges = edges_lines.map { case ((source, dest), s_layer, d_layer) => Edge(source, dest, s_layer) }

       //Defining the Graph
       val graph = Graph(nodes, edges, noedge)
       }
     }

如何在正确的数据类型中转换“节点”,以便我可以制作图表?

0 个答案:

没有答案