For future reference, StackOverflow is a better place, at this point, to
ask "how to?" JUNG-related questions such as this.
There are two different BetweennessCentrality implementations; it looks
like you're using the one in algorithms.importance (the old version) rather
than the one in algorithms.scoring. I recommend the latter.
Normalizing the BetweennessCentrality score is up to you; there are
different ways of doing this depending on what you mean by "normalize".
Two options:
(1) divide all scores by the number of start/end pairs that could have used
that vertex, i.e., (n-1)(n-2)/2
- this will get, for each node, the fraction of all shortest paths that
use that node
(2) find the maximum score, divide all scores by that value
- this will get, for each node, the fraction of the maximum centrality
score that that node has
For all algorithms in algorithms.scoring, to get the score for each vertex
you call [algorithm].getVertexScore([vertex]), just as you did above. The
old way of doing this (algorithms.importance, which gives you
printRankings()) didn't actually expose the scores.
Good luck!
Joshua
On Mon Dec 16 2013 at 1:40:26 PM, Adeeb Noor <ade...@co...>
wrote:
> I am a graduate student who is doing a research on semantic web. I am
> using the Jung library to calculate the closeness and betweenness for my
> network and I have two questions:
>
> 1-Hers is my code to find betweenness:
>
> System.out.println("Applying BetweennessCentrality");
>
> BetweennessCentrality<RDFNode, Statement> Betweenness
> = new BetweennessCentrality<RDFNode, Statement>(graph);
>
> Betweenness.evaluate();
>
> Betweenness.printRankings(true, true);
>
> I got the betweenness score but is there a function to normalize it ? if
> not, what is the best way to do such a thing ?
>
> 2- How can I get the closeness score for all vertices on my graph ? below
> is the code:
>
> System.out.println("Applying ClosenessCentrality");
>
> ClosenessCentrality<RDFNode, Statement> closeness
> = new ClosenessCentrality<RDFNode, Statement>(graph);
>
> closeness.getVertexScore(arg0);
>
> This function will give me the score for only one vertices, however and as
> I said before I want to calculate the closeness score for all vertices in
> my graph. How
>
> finally, I am using java 6 and JUNG 2.0.1 release as api.
>
> Thanks.
>
> --
> Adeeb Noor
> Ph.D. Candidate
> Dept of Computer Science
> University of Colorado at Boulder
> Cell: 571-484-3303
> Email: Ade...@co...
>
|