How to randomly replace part of a kind of atom with another,How to randomly remove some bonds

How to randomly replace part of a kind of atom with another,How to randomly remove some bonds