0.1.3 • Published 11 years ago

ancestor v0.1.3

Weekly downloads
4
License
-
Repository
github
Last release
11 years ago

#Most recent common ancestor an implementation in javascript.

var findAncestor = require('ancestor')

var nodes = {
  1: [],
  2: [1],
  3: [2],
  4: [2],
  5: [4],
  6: [3, 5],
  7: [6],
  8: [5],
  9: [8]
}

/* the graph:

    4-5-8-9   
   /   \
1-2-3---6-7

*/

var readParents = function(id) {
  return nodes[id]
}

var result = findAncestor([9, 7], readParents)
// returns:
5
0.1.3

11 years ago

0.1.2

11 years ago

0.1.0

11 years ago

0.0.1

11 years ago