Skip to content

Instantly share code, notes, and snippets.

@peterneubauer
Last active December 18, 2015 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterneubauer/5857879 to your computer and use it in GitHub Desktop.
Save peterneubauer/5857879 to your computer and use it in GitHub Desktop.
== The Neo4j GraphGist Console. ==
This is a sample GraphGist explaining some of the base concepts of sharing graphs using http://docs.neo4j.org/chunked/snapshot/cypher-query-lang.html[the Cypher query language].
[source,cypher]
----
CREATE ({name:'you'})-[:SEE]->({name:'This GraphGist'})-[:FORK_ON_GITHUB]->(your_gistfile{name:'Your Gist'})
CREATE (your_gistfile)-[:INSERT_ID_HERE]->({name:'Your GraphGist'})
----
* Hover over the nodes to see the +name+ node property in the Graph below.
* Hit the RUN button to execute the query in the <<console>> down below.
//graph1
=== How can I do this? ===
Try forking and editing /#5861321[A very simple GraphGist] to get started.
Other interesting GraphGists:
* /#5878518[Money Laundering]
This document is a GraphGist, see https://gist.github.com/peterneubauer/5857879[This Gist] for the source of this Gist, or click on the Navigation Bar Item.
=== The Rules ===
* GraphGists are shared via Github, and referenced by their Gist ID, e.g. the Github GIST https://gist.github.com/peterneubauer/5857879[https://gist.github.com/peterneubauer/5857879] can be referred to as the Graph GIST http://neo4j-contrib.github.io/graphgist/#5857879[http://neo4j-contrib.github.io/graphgist/#5857879]
* everything is valid ASCIIDOC syntax, with some special comments and naming conventions make this work
* Cypher queries are enumerated in the order they appear, starting at +1+, as source blocks, using +[source,cypher]+ as the denominator.
* before rendering the page, all cypher statements are run against a live, empty Neo4j database in the order they appear
* You can request a live console by using the comment tag +// console+
* You can request a graph vizualisation refering to the graph after the corresponding query number, e.g. +// graph1+ will insert the visualization of the graph after the first query block is run
=== An example Gist ===
Below see the markup for some examples.
// Following is a placeholder for a live console.
// console
//a cypher query, getting the number 2
[source,cypher]
----
CREATE (n{name:'first node'});
----
Some more text after the first Query, using and external image,
++++
<img src="http://chinwag.com/files/logos/events/2221/neo4j_logo.png"/>
++++
Now, let's insert the visualization for the first query.
//The following is a placeholder for the graph visualisation for query 1
//graph2
[source,cypher]
----
CREATE (movie:Movie { title:"Matrix", year: 1999 })
CREATE (movie)<-[:ACTED_IN { role:"Neo" }]-(:Actor { name:"Keanu Reeves", age: 48 })
CREATE (movie)<-[:DIRECTED]-(:Director { name:"Wachowski" }),(movie)<-[:RATED { stars: 5 }]-(:User { login:"Michael" })
RETURN 1;
----
Let's do it for the this query, too
//graph3
[[bonus]]
=== Bonus ===
you can even insert the graphs at different places, repeatedly
//graph1
A non-working query:
[source,cypher]
----
CREATE (movie:Movie RETURN 1;
----
//graph4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment