Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some variable #23

Merged
merged 1 commit into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -85,6 +84,7 @@ object Node2vecAlgo {

(J, q)
}

def setupEdgeAlias(p: Double = 1.0, q: Double = 1.0)(
srcId: Long,
srcNeighbors: Array[(Long, Double)],
Expand All @@ -100,13 +100,15 @@ 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

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 {
Expand Down Expand Up @@ -145,6 +147,7 @@ object Node2vecAlgo {
.cache
this
}

def initTransitionProb(): this.type = {
val bcP = context.broadcast(node2vecConfig.p)
val bcQ = context.broadcast(node2vecConfig.q)
Expand Down Expand Up @@ -172,6 +175,7 @@ object Node2vecAlgo {

this
}

def randomWalk(): this.type = {
val edge2attr = graph.triplets
.map { edgeTriplet =>
Expand Down Expand Up @@ -230,9 +234,9 @@ object Node2vecAlgo {
randomWalkPaths = randomWalk
}
}

this
}

def embedding(): this.type = {
val randomPaths = randomWalkPaths
.map {
Expand Down