NeXTSTEP Programming Mastermind
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

levelgraph-recursive

0.0.1 • Public • Published

LevelGraph-Recursive

Recursive searches for your LevelGraph

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

Keywords

none

install

npm i levelgraph-recursive

Downloadsweekly downloads

46

version

0.0.1

license

ISC

repository

githubgithub

last publish

collaborators

  • avatar