We discuss behaviour of the spectral gap for quantum graphs when two metric graphs are glued together. It appears that precise answer to this question can be given using a natural generalisation of the Titchmarsh-Weyl M-functions.