Models of network formation and financial contagion