diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/config/Configs.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/config/Configs.scala index aa9aad2..9335b29 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/config/Configs.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/config/Configs.scala @@ -355,12 +355,12 @@ object AlgoConstants { val LPA_RESULT_COL: String = "lpa" val CC_RESULT_COL: String = "cc" val SCC_RESULT_COL: String = "scc" - val BETWEENNESS_RESULT_COL: String = "betweennedss" + val BETWEENNESS_RESULT_COL: String = "betweenness" val SHORTPATH_RESULT_COL: String = "shortestpath" val DEGREE_RESULT_COL: String = "degree" val INDEGREE_RESULT_COL: String = "inDegree" val OUTDEGREE_RESULT_COL: String = "outDegree" - val TRIANGLECOUNT_RESULT_COL: String = "tranglecount" + val TRIANGLECOUNT_RESULT_COL: String = "trianglecount" val CLUSTERCOEFFICIENT_RESULT_COL: String = "clustercoefficient" val CLOSENESS_RESULT_COL: String = "closeness" val HANP_RESULT_COL: String = "hanp" diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/KCoreAlgo.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/KCoreAlgo.scala index 633de94..439d093 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/KCoreAlgo.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/KCoreAlgo.scala @@ -15,7 +15,7 @@ import org.apache.spark.sql.{DataFrame, Dataset, Row, SparkSession} object KCoreAlgo { private val LOGGER = Logger.getLogger(this.getClass) - val ALGORITHM: String = "LabelPropagation" + val ALGORITHM: String = "KCore" /** * run the louvain algorithm for nebula graph @@ -42,7 +42,7 @@ object KCoreAlgo { var lastVertexNum: Long = graph.numVertices var currentVertexNum: Long = -1 var isStable: Boolean = false - var iterNum: Int = 1 + var iterNum: Int = 0 var degreeGraph = graph .outerJoinVertices(graph.degrees) { (vid, vd, degree) => diff --git a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/Node2vecAlgo.scala b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/Node2vecAlgo.scala index 1a26943..98e777a 100644 --- a/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/Node2vecAlgo.scala +++ b/nebula-algorithm/src/main/scala/com/vesoft/nebula/algorithm/lib/Node2vecAlgo.scala @@ -1,8 +1,7 @@ /* * Copyright (c) 2021. vesoft inc. All rights reserved. * - * This source code is licensed under Apache 2.0 License, - * attached with Common Clause Condition 1.0, found in the LICENSES directory. + * This source code is licensed under Apache 2.0 License. */ package com.vesoft.nebula.algorithm.lib @@ -85,6 +84,7 @@ object Node2vecAlgo { (J, q) } + def setupEdgeAlias(p: Double = 1.0, q: Double = 1.0)( srcId: Long, srcNeighbors: Array[(Long, Double)], @@ -100,6 +100,7 @@ object Node2vecAlgo { setupAlias(neighbors_) } + def drawAlias(J: Array[Int], q: Array[Double]): Int = { val K = J.length val kk = math.floor(math.random * K).toInt @@ -107,6 +108,7 @@ object Node2vecAlgo { if (math.random < q(kk)) kk else J(kk) } + def load(graph: Graph[None.type, Double]): this.type = { val bcMaxDegree = context.broadcast(node2vecConfig.degree) val bcEdgeCreator = node2vecConfig.directed match { @@ -145,6 +147,7 @@ object Node2vecAlgo { .cache this } + def initTransitionProb(): this.type = { val bcP = context.broadcast(node2vecConfig.p) val bcQ = context.broadcast(node2vecConfig.q) @@ -172,6 +175,7 @@ object Node2vecAlgo { this } + def randomWalk(): this.type = { val edge2attr = graph.triplets .map { edgeTriplet => @@ -230,9 +234,9 @@ object Node2vecAlgo { randomWalkPaths = randomWalk } } - this } + def embedding(): this.type = { val randomPaths = randomWalkPaths .map {