Coment utiliser l'algorithme HITS de JUNG?

Résolu/Fermé
Aaa_dh Messages postés 10 Date d'inscription mardi 26 janvier 2016 Statut Membre Dernière intervention 11 avril 2016 - 1 févr. 2016 à 13:47
Aaa_dh Messages postés 10 Date d'inscription mardi 26 janvier 2016 Statut Membre Dernière intervention 11 avril 2016 - 9 févr. 2016 à 17:00
Bonjour à tous;
Je suis entrain d'essayer d'utiliser le fameux algorithme HITS de jung. Cet algorithme prend comme input un graphe. j'ai donc construit mon graphe pour ensuite le passer comme paramètre à cet algorithme. Cependant, en l'essayant sut Eclipse, il m'affiche l'erreur suivante:

Exception in thread "main" java.lang.ClassCastException: java.lang.String
cannot be cast to edu.uci.ics.jung.graph.Vertex
at com.tweets.algorithms.HITS.initialize(HITS.java:52)
at com.tweets.algorithms.HITS.<init>(HITS.java:41)
at com.tweets.test.Main.main(Main.java:121)


voila comment j'ai crée le graphe:
private static String getId(int nodeId){
return "Node " + nodeId;
}



private static String getId(int nodeId, int neighborId){
return "Edge " + nodeId + " -> " + neighborId;
}



public static Graph<String, Integer> createGraph1(String graphId,
boolean[][] adjacencyMatrix){
Graph<String,Integer> g = new DirectedSparseGraph <String,Integer>();

for (int nodeId = 0; nodeId < adjacencyMatrix.length; nodeId++)
g.addVertex(getId(nodeId));


for (int nodeId = 0; nodeId < adjacencyMatrix.length; nodeId++)
for (int neighborId = 0; neighborId < adjacencyMatrix[nodeId].length; neighborId++)
if (adjacencyMatrix[nodeId][neighborId])
//g.addEdge(getId(nodeId, neighborId),nodeId , neighborId);
g.addEdge(neighborId,getId(nodeId),getId(neighborId));

return(g);

}


et avec le bloc suivant j'appelle l'algorithme HITs dans ma classe main:
HITS ranker = new HITS(g);
ranker.evaluate();
ranker.printRankings(true,false);


et l'IDE indique que l'erreur est dabs ce blob de code de la classe HITS:
protected void initialize(Graph g) {

super.initialize(g, true, false);

mPreviousAuthorityScores = new HashMap();
mPreviousHubScores = new HashMap();

for (Iterator vIt = g.getVertices().iterator(); vIt.hasNext();) {
Vertex currentVertex = (Vertex) vIt.next();
setRankScore(currentVertex, 1.0, AUTHORITY_KEY);
setRankScore(currentVertex, 1.0, HUB_KEY);

mPreviousAuthorityScores.put(currentVertex, new MutableDouble(0));
mPreviousHubScores.put(currentVertex, new MutableDouble(0));
}
}


et plus précisement dans cette ligne de code:
Vertex currentVertex = (Vertex) vIt.next();

Je suis sure quil s'agit d'une erreur de cast, mais je ne sais pas comment la résoudre, et comment faire pour faire correspndre les deux types "Vertex" et String"!!!!!
Aidez moi svp c'est très urgent .
A voir également:

1 réponse

KX Messages postés 16734 Date d'inscription samedi 31 mai 2008 Statut Modérateur Dernière intervention 24 avril 2024 3 015
1 févr. 2016 à 20:27
Bonjour,

Merci de préciser les versions que tu utilises et les import que tu as fait, d'après la documentation le code que tu écris est déprécié...

http://jung.sourceforge.net/doc/api/edu/uci/ics/jung/algorithms/importance/HITS.html
0
Aaa_dh Messages postés 10 Date d'inscription mardi 26 janvier 2016 Statut Membre Dernière intervention 11 avril 2016
9 févr. 2016 à 17:00
0