Gelly CommunityDetection in scala example

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Gelly CommunityDetection in scala example

Trevor Grant
The following example in the scala shell worked as expected:

import org.apache.flink.graph.library.LabelPropagation

val verticesWithCommunity = graph.run(new LabelPropagation(30))

// print the result
verticesWithCommunity.print


I tried to extend the example to use CommunityDetection:

import org.apache.flink.graph.library.CommunityDetection

val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))

// print the result
verticesWithCommunity.print


And meant the following error:
error: polymorphic expression cannot be instantiated to expected type;
found : [K]org.apache.flink.graph.library.CommunityDetection[K]
required: org.apache.flink.graph.GraphAlgorithm[Long,String,Double,?]
val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))
^

I haven't been able to come up with a hack to make this work. Any advice/bug?

I invtestigated the code base a little, seems to be an issue with what Graph.run expects to see vs. what LabelPropagation returns vs. what CommunityDetection returns.



Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil

Reply | Threaded
Open this post in threaded view
|

Re: Gelly CommunityDetection in scala example

Suneel Marthi

On Wed, Apr 27, 2016 at 11:35 AM, Trevor Grant <[hidden email]> wrote:
The following example in the scala shell worked as expected:

import org.apache.flink.graph.library.LabelPropagation

val verticesWithCommunity = graph.run(new LabelPropagation(30))

// print the result
verticesWithCommunity.print


I tried to extend the example to use CommunityDetection:

import org.apache.flink.graph.library.CommunityDetection

val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))

// print the result
verticesWithCommunity.print


And meant the following error:
error: polymorphic expression cannot be instantiated to expected type;
found : [K]org.apache.flink.graph.library.CommunityDetection[K]
required: org.apache.flink.graph.GraphAlgorithm[Long,String,Double,?]
val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))
^

I haven't been able to come up with a hack to make this work. Any advice/bug?

I invtestigated the code base a little, seems to be an issue with what Graph.run expects to see vs. what LabelPropagation returns vs. what CommunityDetection returns.



Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil


Reply | Threaded
Open this post in threaded view
|

Re: Gelly CommunityDetection in scala example

Vasiliki Kalavri
Hi Trevor,

note that the community detection algorithm returns a new graph where the vertex values correspond to the computed communities. Also, note that the current implementation expects a graph with java.lang.Long vertex values and java.lang.Double edge values.

The following should work:

import java.lang.Long
import java.lang.Double

...

val graph: Graph[Long, Long, Double] = ... // create your graph
val resultGraph = graph.run(new CommunityDetection[Long](30, 0.5))
resultGraph.getVertices.print()


Cheers,
-Vasia.

On 27 April 2016 at 17:41, Suneel Marthi <[hidden email]> wrote:

On Wed, Apr 27, 2016 at 11:35 AM, Trevor Grant <[hidden email]> wrote:
The following example in the scala shell worked as expected:

import org.apache.flink.graph.library.LabelPropagation

val verticesWithCommunity = graph.run(new LabelPropagation(30))

// print the result
verticesWithCommunity.print


I tried to extend the example to use CommunityDetection:

import org.apache.flink.graph.library.CommunityDetection

val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))

// print the result
verticesWithCommunity.print


And meant the following error:
error: polymorphic expression cannot be instantiated to expected type;
found : [K]org.apache.flink.graph.library.CommunityDetection[K]
required: org.apache.flink.graph.GraphAlgorithm[Long,String,Double,?]
val verticesWithCommunity = graph.run(new CommunityDetection(30, 0.5))
^

I haven't been able to come up with a hack to make this work. Any advice/bug?

I invtestigated the code base a little, seems to be an issue with what Graph.run expects to see vs. what LabelPropagation returns vs. what CommunityDetection returns.



Trevor Grant
Data Scientist

"Fortunate is he, who is able to know the causes of things."  -Virgil