@dbloc read a similar algorithm scientific paper and then come back to us:
http://www.faculty.idc.ac.il/ariā¦