Skip to content

Instantly share code, notes, and snippets.

@peterneubauer
Forked from nawroth/tutorial-graphgist
Created June 28, 2013 08:19
Show Gist options
  • Save peterneubauer/5883261 to your computer and use it in GitHub Desktop.
Save peterneubauer/5883261 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 the Cypher query language.

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.

How can I do this?

Try forking and editing A very simple GraphGist to get started.

Other interesting GraphGists:

This document is a GraphGist, see 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/nawroth/5880880 can be referred to as the Graph Gist http://neo4j-contrib.github.io/graphgist/#5880880.

  • Everything is valid AsciiDoc syntax, with some magic comments thrown in for extra fun.

  • Cypher queries are added as source blocks, use [source,cypher] as the denominator.

  • All cypher statements are executed against a live, empty Neo4j database in the order they appear. The data is retained between the queries.

  • You can request a live console by using the comment tag // console

  • You can request a graph visualization referring 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.

CREATE (n{name:'first node'});

Some more text after the first Query, using an external image,

Now, let’s insert the visualization for the second query.

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 above query, too.

A non-working query:

CREATE (movie:Movie RETURN 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment