Theory of Cooperation in Complex Social Networks