Homotopy and singular homology groups of finite (di)graphs