Component id of node

Fermé
amelmila Messages postés 7 Statut Membre -  
crapoulou Messages postés 42848 Date d'inscription   Statut Modérateur, Contributeur sécurité Dernière intervention   -
I need to get the connected component id of node and it size I am use graphstream I have try this code
HashMap<Node, ConnectedComponent> componentsMap = null;
Graph graph = new DefaultGraph("CC Test");

graph.addNode("A");
graph.addNode("B");
graph.addNode("C");
graph.addNode("D");
graph.addNode("E");
graph.addNode("F");
graph.addEdge("AB", "A", "B");
graph.addEdge("AC", "A", "C");
graph.addEdge("AD", "A", "D");
graph.addEdge("AE", "A", "E");

ConnectedComponents cc = new ConnectedComponents();
cc.init(graph);
cc.setCountAttribute("cc");
cc.compute();
ConnectedComponent get = componentsMap.get(graph.getNode("A"));
System.out.printf(get.id+"ddddddddd\n");
I get this massege
Exception in thread "main" java.lang.NullPointerException
at javaapplication55.CCTest1.main(CCTest1.java:45)
at this line
ConnectedComponent get = componentsMap.get(graph.getNode("A"));

1 réponse

crapoulou Messages postés 42848 Date d'inscription   Statut Modérateur, Contributeur sécurité Dernière intervention   8 017
 
Hi,

Please ask your question on our English section :
http://ccm.net/forum/
0