Java Code Examples for org.neo4j.graphdb.GraphDatabaseService#getAllRelationships()

The following examples show how to use org.neo4j.graphdb.GraphDatabaseService#getAllRelationships() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GraphBatchImplMultipleLoadTest.java    From SciGraph with Apache License 2.0 6 votes vote down vote up
@Test
public void testMultipleInserts() throws IOException {
  Graph batchGraph = getBatchGraph();
  long a = batchGraph.createNode("a");
  long b = batchGraph.createNode("b");
  batchGraph.createRelationship(a, b, TYPE);
  batchGraph.shutdown();
  batchGraph = getBatchGraph();
  a = batchGraph.createNode("a");
  long c = batchGraph.createNode("c");
  batchGraph.createRelationship(a, c, TYPE);
  batchGraph.shutdown();
  GraphDatabaseService graphDb = getGraphDB();
  try (Transaction tx = graphDb.beginTx()) {
    Iterable<Node> nodes = graphDb.getAllNodes();
    assertThat(size(nodes), is(3));
    Iterable<Relationship> relationships = graphDb.getAllRelationships();
    assertThat(size(relationships), is(2));
    tx.success();
  }
}
 
Example 2
Source File: GraphDump.java    From SciGraph with Apache License 2.0 5 votes vote down vote up
public static void dumpGraph(GraphDatabaseService graphDb) {
  for (Node node: graphDb.getAllNodes()) {
    dumpNode(node);
  }
  for (Relationship relationship: graphDb.getAllRelationships()) {
    dumpRelationship(relationship);
  }
}
 
Example 3
Source File: Neo4jHelper.java    From timbuctoo with GNU General Public License v3.0 5 votes vote down vote up
public static void dumpDb(GraphDatabaseService gds) {
  for (Node node : gds.getAllNodes()) {
    System.out.println(dumpNode(node));
  }
  for (Relationship rel : gds.getAllRelationships()) {
    System.out.println(dumpEdge(rel));
  }
}