Skip to content

Instantly share code, notes, and snippets.

@rvanbruggen
Created May 25, 2013 18:03
Show Gist options
  • Save rvanbruggen/5650102 to your computer and use it in GitHub Desktop.
Save rvanbruggen/5650102 to your computer and use it in GitHub Desktop.
******************************************
*** Some cool ConceptNet Graph Queries ***
******************************************
*** Look up a concept in the Graph ***
START beer=node:Concepts(id="/c/en/beer")
return beer;
*** Figure out the relations of a concept to other concepts ***
START sushi=node:Concepts(id="/c/en/sushi")
MATCH sushi-[r]-other_concepts
RETURN sushi.id, TYPE(r), other_concepts.id;
START beer=node:Concepts(id="/c/en/beer")
MATCH beer-[r]-other_concepts
RETURN beer.id, TYPE(r), other_concepts.id;
*** Find ALL Shortest Paths between two concepts ***
START
sushi=node:Concepts(id="/c/en/sushi"),
beer=node:Concepts(id="/c/en/beer")
MATCH
p = AllShortestPaths(sushi-[*..10]-beer)
return p;
START
car=node:Concepts(id="/c/en/car"),
beer=node:Concepts(id="/c/en/beer")
MATCH
p = AllShortestPaths(car-[*..10]-beer)
return p;
START
wine=node:Concepts(id="/c/en/wine"),
beer=node:Concepts(id="/c/en/beer")
MATCH
p = AllShortestPaths(wine-[*..10]-beer)
return p;
*** Find *a* Shortest Path between two concepts ***
START
sushi=node:Concepts(id="/c/en/sushi"),
beer=node:Concepts(id="/c/en/beer")
MATCH
p = ShortestPath(sushi-[*..10]-beer)
return p;
START
car=node:Concepts(id="/c/en/car"),
beer=node:Concepts(id="/c/en/beer")
MATCH
p = ShortestPath(car-[*..10]-beer)
return p;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment