Theoretical framework for quantum networks