[Neo] Create/Modify Graph
anders at neotechnology.com
Tue Feb 16 19:42:00 CET 2010
> 1. How do I add nodes to an existing graph? So far, I created a simple graph which stored in var/base and visible from neoclipse, however when I modify my script to create additional nodes and relationship, changes are not visible in neoclipse, although I quit neoclise prior to adding nodes and edges.
Older Neoclipse versions have problems finding the nodes if they are not
connected somehow to the reference node. If you're not using it already,
try the snapshot version:
or try a recent standalone version:
If that's not the problem, it could be that you forgot to mark the
transaction as successful, see:
> 2. How do I list overall relationship? I found graphDb.getAllNodes() but not graphDb.getAllRelationship(), nor graphDb.getNumberOfRelationship() to loop through. Of course I understand that the prefered solution would be to traverse the graph, but before going further in learning about neo4j, I just wanted to check that node and edge creations succeeded.
You'll have to either find the relationships through traversal, from the
nodes or by using GraphDatabaseService.getRelationshipById().
> 3. What happen if I create a node that already exists - for instance when I rerun my code? I get no error message on existing nodes, but new nodes are not created either or at list not visible in neoclipse.
If you rerun your code using the same neo4j store, you'll end up with
lots of nodes in it! You can't technically add "the same node twice", as
the Ids of the nodes will differ.
> Thanks in advance for answers,
> Neo mailing list
> User at lists.neo4j.org
More information about the User