Index theorems for quantum graphs