Skip to content
Open
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 @@ -16,6 +16,8 @@

public class SparkGraphUtil implements GraphUtil<Dataset<Row>, Row, Column> {

public static final String CONNECTED_COMPONENTS_ALGORITHM = "two_phase";

public ZFrame<Dataset<Row>, Row, Column> buildGraph(ZFrame<Dataset<Row>, Row, Column> vOrig, ZFrame<Dataset<Row>, Row, Column> ed) {
// we need to transform the input here by using stop words
//rename id field which is a common field in data to another field as it
Expand All @@ -37,7 +39,8 @@ public ZFrame<Dataset<Row>, Row, Column> buildGraph(ZFrame<Dataset<Row>, Row, Co
GraphFrame gf = new GraphFrame(v, e);
//gf = gf.dropIsolatedVertices();
//Dataset<Row> returnGraph = gf.connectedComponents().setAlgorithm("graphx").run().cache();
Dataset<Row> returnGraph = gf.connectedComponents().run().cache();
Dataset<Row> returnGraph = gf.connectedComponents()
.setAlgorithm(CONNECTED_COMPONENTS_ALGORITHM).run().cache();
//reverse back o avoid graphframes id :-()
returnGraph = returnGraph.join(vertices, returnGraph.col("id").equalTo(vertices.col(ColName.ID_COL)));
returnGraph = returnGraph.drop(ColName.ID_COL).withColumnRenamed("id", ColName.ID_COL);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package zingg.spark.core.util;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;

public class TestSparkGraphUtilConfiguration {

@Test
public void connectedComponentsAlgorithmIsExplicitlyConfigured() {
assertEquals("two_phase", SparkGraphUtil.CONNECTED_COMPONENTS_ALGORITHM);
}
}