Search code examples
rubyrestgraph-theoryneo4jtopological-sort

Topological Sort on Neo4j


I have a graph on neo4j and I would like to run a topological sort, preferably without writing on the graph itself (to allow for multiple clients to run algorithms on the same graph simultaneously).

How should I approach this? Shall I clone the graph and work on the temporary copy, or is there a sort of traversal/iterator ?

thanks

PS: I'm using neo4J through the neography gem (REST API) on Ruby


Solution

  • Dan,

    You can start a transaction and fail it once you have the data you need so it won't write to the database. See http://maxdemarzi.com/2012/02/21/max-flow-with-gremlin-and-transactions/ for an example. This won't work too well if you have to touch a million nodes, but for small subsets of the graph it should be no problem.