Abstract. The question of how to stabilize financial systems has attracted considerable attention since the global financial crisis of -2009. Recently, Beale et al. [Proc. Natl. Acad. Sci. USA 108, 12647 (2011] demonstrated that higher portfolio diversity among banks would reduce systemic risk by decreasing the risk of simultaneous defaults at the expense of a higher likelihood of individual defaults. In practice, however, a bank default has an externality in that it undermines other banks' balance sheets. This paper explores how each of these different sources of risk, simultaneity risk and externality, contributes to systemic risk. The results show that the allocation of external assets that minimizes systemic risk varies with the topology of the financial network as long as asset returns have negative correlations. In the model, a well-known centrality measure, PageRank, reflects an appropriately defined "infectiveness" of a bank. An important result is that the most infective bank needs not always to be the safest bank. Under certain circumstances, the most infective node should act as a firewall to prevent large-scale collective defaults. The introduction of a counteractive portfolio structure will significantly reduce systemic risk.