naive NW algorithm