0

I am trying to execute a very simple code for community detection but it returns an error:

import org.apache.flink.graph.library.CommunityDetection
import org.apache.flink.graph._
import org.apache.flink.graph.scala.Graph
import java.lang.Long
import java.lang.Double
import org.apache.flink.api.scala._

val env = ExecutionEnvironment.getExecutionEnvironment
val vertices = Seq(new Vertex[Long, String](1L, "foo"), new Vertex[Long, String](2L, "bar"))
val edges = Seq(new Edge[Long, String](1L, 2L, "foobar"))

val graph = Graph.fromCollection(vertices, edges, env)
val updatedGraph = graph.mapVertices(v => v.getValue + 1)
val resultGraph = graph.run(new CommunityDetection[Long](30, 0.5))


                            ^
Dzmitry Haikov
  • 199
  • 1
  • 2
  • 6
  • Error:(30, 33) type mismatch; found : org.apache.flink.graph.library.CommunityDetection[Long] required: org.apache.flink.graph.GraphAlgorithm[Long,String,String,?] val resultGraph = graph.run(new CommunityDetection[Long](30, 0.5)) – Dzmitry Haikov Aug 26 '16 at 22:50

1 Answers1

0

The CommunityDetection algorithm expects a Graph with Long Ids and vertex values and Double edge weights. In your code, you define String values for the vertices and the edges. Please, look at the Gelly documentation for more detailed usage information.

vasia
  • 136
  • 3
  • I am using the following code and still get an exception. Could you give an example of a working code, please? Thank you. val env = ExecutionEnvironment.getExecutionEnvironment val vertices = Seq(new Vertex[Long, Double](1L, 0.1), new Vertex[Long, Double](2L, 0.4)) val edges = Seq(new Edge[Long, Double](1L, 2L, 0.5)) val graph = Graph.fromCollection(vertices, edges, env) – Dzmitry Haikov Sep 02 '16 at 12:21
  • The problem is that you are using `Double` vertex values. Both vertex ids and values have to be `Long`. Try replacing your vertex creation with e.g. `val vertices = Seq(new Vertex[Long, Long](1L, 1L), new Vertex[Long, Long](2L, 4L))`. – vasia Sep 02 '16 at 15:00