Nearly Optimal Best-of-Both-Worlds Algorithms for Online Learning with Feedback Graphs