Green function approach for general quantum graphs