Contribution:
gremlin-neo4j
Headline
A graph-based implementation using Neo4J and the Gremlin graph query DSL
Motivation
This implementation uses the Technology:Neo4j Technology:Graph database to directly map the 101companies Feature:Hierarchical company to the database model.
Illustration
Employees and departments both are modelled as nodes with names and addresses as properties. Employment, Management and Subdepartment relations are modelled as the graph's edges. Salaries are considered properties of employment and therefore annotated to the corresponding edges.
- Employment is marked via edges with a "EMPLOYED" relation.
- A department having a subdepartment is shown by an edge with the "HAS SUBUNIT" relation.
- An employee being manager of a department is noted via the "MANAGES" relation.
g.V.outE('EMPLOYED').collect{it.salary}.flatten().sum()
To cut the salaries of employees, Gremlin has to set the value of a property which is treated as a side effect and properly signaled by the use of the sideEffect method:
g.V.out('EMPLOYED').sideEffect{it.salary = (double)it.salary / 2.0}
Note that there has to be a cast in the division as Groovy treats the results of division as BigDecimal rather than double.
Gremlin scripts can be executed on Neo4J via its REST API. Example queries can be sent via the UNIX tool curl, either directly as payload to a request to the respective URL at the local database host:
$ curl -d "script=$MYSCRIPT" http://localhost:7474/db/data/ext/GremlinPlugin/graphdb/execute script
Please note that special characters in the script need to be properly escaped.
Usage
There are three shellscripts that send the respective commands to a local running Neo4J database on default port 7474. Please make sure that no other content is hosted on the local database! Run rebuild.sh to insert the example information into the database:
$ ./rebuild.sh
The basic features are demonstrated by running the respective shellscripts such as:
$ ./total.js
Each script will print out the results of the respective computation.
There are no revisions for this page.
User contributions
User edits
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.
Syntax for editing wiki
For you are available next options:will make text bold.
will make text italic.
will make text underlined.
will make text striked.
will allow you to paste code headline into the page.
will allow you to link into the page.
will allow you to paste code with syntax highlight into the page. You will need to define used programming language.
will allow you to paste image into the page.
is list with bullets.
is list with numbers.
will allow your to insert slideshare presentation into the page. You need to copy link to presentation and insert it as parameter in this tag.
will allow your to insert youtube video into the page. You need to copy link to youtube page with video and insert it as parameter in this tag.
will allow your to insert code snippets from @worker.