-2

I am trying to write a plugin for Gephi and get the following error message:

java.lang.ClassCastException: org.gephi.graph.impl.GraphStore$NodeIterableWrapper cannot be cast to org.gephi.graph.api.Node at org.............execute(.....java:92)

The code in which the error occurred:

Node[] nodes = graph.getNodes().toArray();
for (Node n: nodes){
    .....
    List<Node> neighborNodes = new LinkedList<Node>();
    for(Node m: nodes){
        NodeIterable iter = graph.getNeighbors(m);
        neighborNodes.add((Node) iter);

The last line causes the error. Is it possible via NodeIterable to insert the neighbors as nodes in the list neighborNodes without this cast? I'm new to writing Java plugins.

user4157124
  • 2,809
  • 13
  • 27
  • 42
Code Now
  • 11
  • 3

1 Answers1

0

According to this javadoc, NodeIterable is an Iterable of Nodes.

So you probably should use a loop:

NodeIterable iter = graph.getNeighbors(m);
for (Node n: iter) {
    neighborNodes.add(n);
}

or addAll and toCollection:

NodeIterable iter = graph.getNeighbors(m);
neighborNodes.addAll(iter.toCollection());