Skip to content

Commit

Permalink
chore: typo fixes and added import for examples (#19)
Browse files Browse the repository at this point in the history
this may help fresh user to copy/paste and run smoothly
  • Loading branch information
wey-gu committed Dec 2, 2021
1 parent 0337b2b commit a37e0db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
7 changes: 6 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ nebula-algorithm 是一款基于 [GraphX](https://spark.apache.org/graphx/) 的
```
* 定义算法参数调用算法(以`PageRank`为例)
```
import com.vesoft.nebula.algorithm.config.{Configs, PRConfig, SparkConfig}
import org.apache.spark.sql.{DataFrame, SparkSession}
val spark = SparkSession.builder().master("local").getOrCreate()
val data = spark.read.option("header", true).csv("src/test/resources/edge.csv")
val prConfig = new PRConfig(5, 1.0)
val louvainResult = PageRankAlgo.apply(spark, data, prConfig, false)
val prResult = PageRankAlgo.apply(spark, data, prConfig, false)
```

其他算法的调用方法见[测试示例](https://github.com/vesoft-inc/nebula-algorithm/tree/master/nebula-algorithm/src/test/scala/com/vesoft/nebula/algorithm/lib)
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,13 @@ Limitation: Due to Nebula Algorithm will not encode string id, thus during the a
```
* Instantiate algorithm's config, below is an example for `PageRank`.
```
import com.vesoft.nebula.algorithm.config.{Configs, PRConfig, SparkConfig}
import org.apache.spark.sql.{DataFrame, SparkSession}
val spark = SparkSession.builder().master("local").getOrCreate()
val data = spark.read.option("header", true).csv("src/test/resources/edge.csv")
val prConfig = new PRConfig(5, 1.0)
val louvainResult = PageRankAlgo.apply(spark, data, prConfig, false)
val prResult = PageRankAlgo.apply(spark, data, prConfig, false)
```

For other algorithms, please refer to [test cases](https://github.com/vesoft-inc/nebula-algorithm/tree/master/nebula-algorithm/src/test/scala/com/vesoft/nebula/algorithm/lib).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import org.junit.Test
class PageRankAlgoSuite {
@Test
def pageRankSuite(): Unit = {
val spark = SparkSession.builder().master("local").getOrCreate()
val data = spark.read.option("header", true).csv("src/test/resources/edge.csv")
val prConfig = new PRConfig(5, 1.0)
val louvainResult = PageRankAlgo.apply(spark, data, prConfig, false)
assert(louvainResult.count() == 4)
val spark = SparkSession.builder().master("local").getOrCreate()
val data = spark.read.option("header", true).csv("src/test/resources/edge.csv")
val prConfig = new PRConfig(5, 1.0)
val prResult = PageRankAlgo.apply(spark, data, prConfig, false)
assert(prResult.count() == 4)
}
}

0 comments on commit a37e0db

Please sign in to comment.