A statistical mechanics approach to Granovetter theory