Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mcollina/levelgraph-recursive

Breadth-first and Deep-first for your LevelGraph
https://github.com/mcollina/levelgraph-recursive

Last synced: 2 months ago
JSON representation

Breadth-first and Deep-first for your LevelGraph

Awesome Lists containing this project

README

        

LevelGraph-Recursive
====================

Recursive searches for your LevelGraph

```js
var levelgraph = require('levelgraph')
, graph = levelgraph('mygraph')
, expect = require("must")

graph = require('levelgraph-recursive')(graph)

graph.put([{
subject: 'origin'
, predicate: 'similar'
, object: 'a'
}, {
subject: 'a'
, predicate: 'similar'
, object: 'b'
}, {
subject: 'a'
, predicate: 'similar'
, object: 'c'
}, {
subject: 'c'
, predicate: 'similar'
, object: 'd'
}, {
subject: 'b'
, predicate: 'similar'
, object: 'dest'
}, {
subject: 'd'
, predicate: 'similar'
, object: 'dest'
}], function() {
graph.breadthFirst("origin", "similar", "dest", function(err, triple) {
expect(triple).to.eql({
subject: 'b'
, predicate: 'similar'
, object: 'dest' });
console.log('breadth first ok!')
})

graph.deepFirst("origin", "similar", "dest", function(err, triple) {
expect(triple).to.eql({
subject: 'd'
, predicate: 'similar'
, object: 'dest' });
console.log('deep first ok!')
})
})
```

License
-------

ISC