The Yamada polynomial of spatial graphs obtained by edge replacements