org.neo4j.io.fs.FileUtils Java Examples

The following examples show how to use org.neo4j.io.fs.FileUtils. 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: DataImporterNorthwindTest.java    From neo4j-rdbms-import with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FileUtils.deleteRecursively(new File(STORE_DIR));
    long time = System.currentTimeMillis();
    Rules rules = new Rules(); // asList("titles")
    new DatabaseImporter("jdbc:mysql://localhost:3306/northwind?user=root", "northwind", STORE_DIR, rules).run();
    long delta = (System.currentTimeMillis() - time) / 1000;
    String result = importInfo();
    System.out.println(result + " in " + delta + " seconds");
}
 
Example #2
Source File: DataImporterSakilaTest.java    From neo4j-rdbms-import with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FileUtils.deleteRecursively(new File(STORE_DIR));
    long time = System.currentTimeMillis();
    new DatabaseImporter("jdbc:mysql://localhost:3306/sakila?user=root", "sakila", STORE_DIR, new Rules()).run();

    long delta = (System.currentTimeMillis() - time) / 1000;
    String result = importInfo();
    System.out.println(result + " in " + delta + " seconds");
}
 
Example #3
Source File: DataImporterEmployeeTest.java    From neo4j-rdbms-import with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    FileUtils.deleteRecursively(new File(STORE_DIR));
    StopWatch watch = new StopWatch();
    Rules rules = new Rules(); // asList("titles")
    new DatabaseImporter("jdbc:mysql://localhost:3306/employees?user=root", "employees", STORE_DIR, rules).run();

    watch.lap("import");
    System.err.println(watch.stop("import", importInfo()));
}
 
Example #4
Source File: DataImporterTest.java    From neo4j-rdbms-import with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    setupDatabase();

    FileUtils.deleteRecursively(new File(STORE_DIR));
    long time = System.currentTimeMillis();
    new DatabaseImporter("jdbc:derby:memory:test", null, STORE_DIR, new Rules()).run();

    String result = assertImport();
    System.out.println(result + " in " + (System.currentTimeMillis() - time) / 1000 + " seconds");
}
 
Example #5
Source File: Neo4jSNAMain.java    From Neo4jSNA with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
       String zipFile = "data/cineasts_12k_movies_50k_actors_2.1.6.zip";
       String path = "data/cineasts_12k_movies_50k_actors.db/";

       try {
           FileUtils.deleteRecursively(new File(path));
           extractFolder(zipFile);
       } catch (Exception e) {
           e.printStackTrace();
           System.exit(1);
       }

       long nodeCount, relsCount;
	
	// Open a database instance
       GraphDatabaseService g = new GraphDatabaseFactory()
               .newEmbeddedDatabaseBuilder(path)
               .setConfig(GraphDatabaseSettings.allow_store_upgrade, "true")
               .newGraphDatabase();
       try (Transaction tx = g.beginTx() ) {
		nodeCount = IteratorUtil.count( GlobalGraphOperations.at(g).getAllNodes() );
		relsCount = IteratorUtil.count( GlobalGraphOperations.at(g).getAllRelationships() );
		tx.success();
	}
	
	System.out.println("Node count: "+nodeCount);
       System.out.println("Rel count: " + relsCount);

       // Declare the GraphAlgoEngine on the database instance
	GraphAlgoEngine engine = new GraphAlgoEngine(g);
	if( args.length > 1 && args[1].equals("off") )
		engine.disableLogging();

       Louvain louvain = new Louvain(g);
       louvain.execute();
       LouvainResult result = louvain.getResult();
       for (int layer : result.layers()) {
           System.out.println("Layer " + layer + ": " + result.layer(layer).size() + " nodes");
       }

       LabelPropagation lp = new LabelPropagation();
       // Starts the algorithm on the given graph g
	engine.execute(lp);
	Long2LongMap communityMap = lp.getResult();
	long totCommunities = new LongOpenHashSet( communityMap.values() ).size();
       System.out.println("There are " + totCommunities + " communities according to Label Propagation");

	DirectedModularity modularity = new DirectedModularity(g);
	engine.execute(modularity);
       System.out.println("The directed modularity of this network is " + modularity.getResult());

       UndirectedModularity umodularity = new UndirectedModularity(g);
	engine.execute(umodularity);
       System.out.println("The undirected modularity of this network is " + umodularity.getResult());

       engine.clean(lp); // Now you can clean Label propagation results

       TriangleCount tc = new TriangleCount();
	engine.execute(tc);
	Long2LongMap triangleCount = tc.getResult();
	Optional<Long> totalTriangles = triangleCount.values().stream().reduce( (x, y) -> x + y );
	System.out.println("There are "+totalTriangles.get()+" triangles");

	PageRank pr = new PageRank(g);
	engine.execute(pr);
	Long2DoubleMap ranks = pr.getResult();
	engine.clean(pr);
	Optional<Double> res = ranks.values().parallelStream().reduce( (x, y) -> x + y );
	System.out.println("Check PageRank sum is 1.0: "+ res.get());

	ConnectedComponents cc = new ConnectedComponents();
	engine.execute(cc);
	Long2LongMap components = cc.getResult();
	engine.clean(cc);
	int totalComponents = new LongOpenHashSet( components.values() ).size();
	System.out.println("There are "+ totalComponents+ " different connected components");
	
	StronglyConnectedComponents scc = new StronglyConnectedComponents();
	engine.execute(scc);
	components = scc.getResult();
	engine.clean(scc);
	totalComponents = new LongOpenHashSet( components.values() ).size();
	System.out.println("There are "+ totalComponents+ " different strongly connected components");
	
	// Don't forget to shutdown the database
	g.shutdown();
}