Since you can run cypher from java the following would be a valid (but
probably not expected) answer:
new ExecutionEngine(graphDb).execute("match (n:MyLabel) optional
match(n)-[r]-() delete r,n");

In pure Java:

try (Transaction tx=graphDb.beginTx()) {
   for (Node n:
GlobalGraphOperations.at(graphDb).getAllNodesWithLabel(DynamicLabel.label("MyLabel")))
{
      for (Relationship r: n.getRelationships()) {
          r.delete();
      }
      n.delete();
   }

   tx.success();
}

NB: didn't test code above it's more a dump from /dev/brain ;-)

/Stefan


2014-08-29 12:35 GMT+02:00 Alireza Rezaei Mahdiraji <[email protected]>:
>
> Hi All,
>
> How can I remove all nodes (and their relationships) with a given label
> using Java?
>
> Thanks,
> Alireza
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to