Hi,
I am having a problem trying to use the
getSubgraphInducedByEdges() method.
Since I needed additional properties for vertices and edges, I subclassed
InMemoryGrph :public class MyGrph extends InMemoryGrph {
public int getVertexByLabel(String label) {
...
}
...
}
After instanciation of a large graph, (~1M vertices, ~8M edges) I search for a vertex given its label, and try to display it and its surrondings but a
NullPointerException is raised.
// search a vertex
String searched = "some vertex label";
int vertex = graph.getVertexByLabel(searched); // MyGrph method
// get its edges
IntSet allEdges = graph.getInEdges(vertex);
IntSet outEdges = graph.getOutEdges(vertex);
allEdges.addAll(outEdges);
// get the subgraph induced by the searched vertex, i.e its
// 1-neighbourhood
Grph subgraph = graph.getSubgraphInducedByEdges(allEdges); // NullPointerException
// display it
subgraph.display();
With the debugger help, it turns out that the Clazz.makeInstance function fails.
// Class: Grph
// Method: public Grph getSubgraphInducedByEdges(IntSet edges)
Grph g = Clazz.makeInstance(getClass()); // returns null
for (IntCursor ec : edges)
{
int e = ec.value;
if (isSimpleEdge(e))
{
int a = getOneVertex(e);
int b = getTheOtherVertex(e, a);
g.addSimpleEdge(a, e, b, isDirectedSimpleEdge(e)); // NullPointerException
I have no idea how to fix this problem.
Any pointers ?
Thanks for your help.
Sharky.