parallel and serial implementations of FW algorithm