Homology for higher-rank graphs and twisted C*-algebras