Working code of the netinf algorithm