Subgraph induced by edges

31 views
Skip to first unread message

Sharky Fr

unread,
Jun 2, 2016, 6:59:18 AM6/2/16
to Grph: High Performance Graph Library for Java
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.

Sharky Fr

unread,
Jun 6, 2016, 5:33:32 AM6/6/16
to Grph: High Performance Graph Library for Java
Solved.

If someone runs into the same issue : make sure the Grph subclass has a default constructor.

Sharky.
Reply all
Reply to author
Forward
0 new messages