Graph database Analysis of the Steam Network
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.1 KiB

  1. sigma.neo4j.cypher
  2. ====================
  3. Plugin developed by [Benoît Simard](https://github.com/sim51).
  4. ---
  5. This plugin provides a simple function, `sigma.neo4j.cypher()`, that will run a cypher query on a neo4j instance, parse the response, eventually instantiate sigma and fill the graph with the `graph.read()` method.
  6. Nodes are created with the following structure :
  7. * id -> Neo4j node id
  8. * label -> Neo4j node id
  9. * neo4j_labels -> Labels of Neo4j node
  10. * neo4j_data -> All the properties of the neo4j node
  11. Edges are created with the following structure :
  12. * id -> Neo4j edge id
  13. * label -> Neo4j edge type
  14. * neo4j_type -> Neo4j edge type
  15. * neo4j_data -> All the properties of Neo4j relationship
  16. The most basic way to use this helper is to call it with a neo4j server url and a cypher query. It will then instantiate sigma, but after having added the graph into the config object.
  17. For neo4j < 2.2
  18. ````javascript
  19. sigma.neo4j.cypher(
  20. 'http://localhost:7474',
  21. 'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  22. { container: 'myContainer' }
  23. );
  24. ````
  25. For neo4j >= 2.2, you must pass a neo4j user with its password. So instead of the neo4j url, you have to pass a neo4j server object like this :
  26. ````javascript
  27. sigma.neo4j.cypher(
  28. { url: 'http://localhost:7474', user:'neo4j', password:'admin' },
  29. 'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  30. { container: 'myContainer' }
  31. );
  32. ````
  33. It is also possible to update an existing instance's graph instead.
  34. ````javascript
  35. sigma.neo4j.cypher(
  36. { url: 'http://localhost:7474', user:'neo4j', password:'admin' },
  37. 'MATCH (n) OPTIONAL MATCH (n)-[r]->(m) RETURN n,r,m LIMIT 100',
  38. myExistingInstance,
  39. function() {
  40. myExistingInstance.refresh();
  41. }
  42. );
  43. ````
  44. There is two additional functions provided by the plugin :
  45. * ```sigma.neo4j.getTypes({ url: 'http://localhost:7474', user:'neo4j', password:'admin' }, callback)``` : Return all relationship type of the database
  46. * ```sigma.neo4j.getLabels({ url: 'http://localhost:7474', user:'neo4j', password:'admin' }, callback)``` : Return all node label of the database