<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                * 構建用戶合作關系屬性圖 * 頂點屬性:用戶名、職業 * 邊屬性:表示合作關系 ![](https://img.kancloud.cn/95/b5/95b524454711401f2b191cc70935ddc5_785x409.png) ```scala import org.apache.spark.SparkContext import org.apache.spark.graphx.{Edge, Graph} import org.apache.spark.rdd.RDD import org.apache.spark.sql.SparkSession object PartnershipGraphx { def main(args: Array[String]): Unit = { val spark:SparkSession = SparkSession.builder() .master("local[4]") .appName(this.getClass.getName) .getOrCreate() val sc:SparkContext = spark.sparkContext import spark.implicits._ // 1. 構建表示用戶的點集合 val users:RDD[(Long, (String, String))] = sc.parallelize(Array( // (點Id, (點名, 點值)) (3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")), (5L, ("franklin", "professor")), (2L, ("istoica", "professor")) )) // 2. 構建表示點與點關系的邊的集合 val relationships:RDD[Edge[String]] = sc.parallelize(Array( // Edge(srcId, dstId, edgeAttr) (Edge(3L, 7L, "collaborator")), (Edge(5L, 3L, "advisor")), (Edge(2L, 5L, "colleague")), (Edge(5L, 7L, "PI")) )) // 3. 使用點集合與邊集合構建圖 // Graph[(點值類型), 邊值類型] val graph:Graph[(String, String), String] = Graph(users, relationships) // 圖所有的頂點 graph.vertices.foreach(x=>println(s"(Id:${x._1}, Attr:${x._2})")) // (Id:2, Attr:(istoica,professor)) // (Id:3, Attr:(rxin,student)) // (Id:5, Attr:(franklin,professor)) // (Id:7, Attr:(jgonzal,postdoc)) // 圖的所有邊 graph.edges.foreach(x=>println(s"(srcId:${x.srcId}, distId:${x.dstId}, edgeAttr:${x.attr})")) // (srcId:2, dstId:5, edgeAttr:colleague) // (srcId:5, dstId:7, edgeAttr:PI) // (srcId:3, dstId:7, edgeAttr:collaborator) // (srcId:5, dstId:3, edgeAttr:advisor) // triplets帶有屬性的點和邊 graph.triplets.foreach(x=>println(x.toString())) // ((srcId, (srcAttr)), (dstID, (dstAttr)), edgeAttr) // ((5,(franklin,professor)),(3,(rxin,student)),advisor) // ((2,(istoica,professor)),(5,(franklin,professor)),colleague) // ((3,(rxin,student)),(7,(jgonzal,postdoc)),collaborator) // ((5,(franklin,professor)),(7,(jgonzal,postdoc)),PI) } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看