Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use neo4j with R

Tags:

graph

r

neo4j

bulbs

Is there a R library that supports neo4j? I would like to construct a R graph (e.g. igraph) from neo4j or - vice versa - store a R graph in neo4j.

More precisely, I am looking for something similar to bulbflow for Python.


Update

There is a new neo4j driver for R that looks promising: http://nicolewhite.github.io/RNeo4j/. I changed the correct answer.

like image 228
Martin Preusse Avatar asked Jun 25 '12 11:06

Martin Preusse


People also ask

What are the weaknesses of Neo4j?

Additionally, Neo4j has scalability weaknesses related to scaling writes, hence if your application is expected to have very large write throughputs, then Neo4j is not for you.

Is Neo4j faster than PostgreSQL?

We found that, while Neo4j is more time intensive to implement, its queries are less complex and have a faster runtime than comparable queries performed in PostgreSQL.

Is Neo4j the best graph database?

Neo4j — “Open-source graph database” Created in 2007, Neo4j is ranked as the #1 graph database by db-engines.com. Neo4j is open-sourced and supports a wide range of programming languages including: . Net, Clojure, Elixir, Go, Groovy, Haskell, Java, JavaScript, Perl, PHP, Python, Ruby, and Scala.

Is Neo4j used in industry?

8 of the Top 10 AutomakersTop automakers like Volvo Cars, Daimler and Toyota rely on Neo4j to drive innovative manufacturing solutions.


2 Answers

This link might be helpful. I'm going to connect ne04j with R in the following days and will try first with the provided link. Hope it helps.

I tried it out and it works well. Here is the function that works: First, install and load packages and then execute function:

install.packages('RCurl')
install.packages('RJSONIO')

library('bitops')
library('RCurl')
library('RJSONIO')

query <- function(querystring) {
  h = basicTextGatherer()
  curlPerform(url="localhost:7474/db/data/ext/CypherPlugin/graphdb/execute_query",
    postfields=paste('query',curlEscape(querystring), sep='='),
    writefunction = h$update,
    verbose = FALSE
  )           
  result <- fromJSON(h$value())
  #print(result)
  data <- data.frame(t(sapply(result$data, unlist)))
  print(data)
  names(data) <- result$columns

}

and this is an example of calling function:

q <-"start a = node(50) match a-->b RETURN b"
 data <- query(q)
like image 182
Niko Gamulin Avatar answered Oct 16 '22 03:10

Niko Gamulin


Consider the RNeo4j driver. The function shown above is incomplete: it cannot return single column data and there is no NULL handling.

https://github.com/nicolewhite/RNeo4j

like image 26
Nicole White Avatar answered Oct 16 '22 04:10

Nicole White