0

I am having a strange problem while trying to visualize a Neo4jGraph in Java. I create a GraphJung graphjung object and try to access Vertex an Edge properties defined previously. Even though Edge labels can be retrieved correctly, Vertices seem to have no properties set whatsoever. Segments of the code are below:

Neo4jVertex c = (Neo4jVertex) graph.addVertex(null);
c.setProperty("name", ("In_"+i));

(...)

Cs.put("C_"+i, c); // a TreeMap with vertices saved.
Edge e = graph.addEdge(null, Cs.get("C_"+i), Cs.get("C_"+cToConnect), name);

(...)

// Render created graph online
Rendering render = new Rendering();
render.visualize(new GraphJung<Neo4jGraph>(graph));

And, inside visualize(), the following code returns a null object when calling .setproperty():

// Set the labels in Vertices.
Transformer<Vertex, String> vertexLabelTransformer = new Transformer<Vertex, String>() {
    public String transform(Vertex vertex) {
        **return (String)vertex.getProperty("name");**
    }
};

Edges code works fine though:

// Set the labels in Edges.
Transformer<Edge, String> edgeLabelTransformer = new Transformer<Edge, String>() {
    public String transform(Edge edge) {
        return edge.getLabel();
    }
};
  • Did you use transactions and also commit them? So your data is actually in the graph? Can you verify otherwise that your data was added to the graph? – Michael Hunger May 11 '14 at 21:09
  • Perhaps you can share your whole project on github to make it possible for others to reproduce? – Michael Hunger May 11 '14 at 21:10
  • No, I did not use any Transactions nor commit them, at least not up to this point in development. I did verify that information is in with system.out.println and .getProperty... Isn't that enough? I am new to blueprints and Neo4jGraph so I didn't know that this is needed. Is it possible that you provide a really simple example of this? Unfortunately I cannot share the entire project since I am not allowed to do that on this stage of development. Thanks for the help. – G. Stergiopoulos May 12 '14 at 11:16
  • Ok, you were correct. I didn't use any Transactions but I was writing directly on the graph using graph.setProperty(). All I had to do was to use the instruction graph.commit(); before casting the graph to GraphJung. Thank you very much. – G. Stergiopoulos May 12 '14 at 16:28

0 Answers0