Disentangling homophily, community structure and triadic closure in networks