I am using JUNG to perform social network analysis. I would like to know how to implement the K-Coreness of a given node in a graph using JUNG. Or else is there any other library which I can use to compute the K-Coreness of a given node in a graph using java.
Thank you Dinusha
JUNG does not include an implementation of the k-core algorithm, but the basic idea is easy to implement for a given k:
boolean removedVertex = false;
while (!removedVertex && graph.getVertexCount() > 0) {
for (V v : graph.getVertices()) {
if (graph.getDegree(v) < k) {
graph.removeVertex(v);
removedVertex = true;
}
}
}
// at this point the graph is either empty or all remaining vertices
// have degree >= k
(There are probably more clever/efficient implementations, but this should work as long as the graph isn't huge.)