Optimal path and directed percolation