How LLMs Learn to Reason: A Complex Network Perspective