check whether source, target and ports exists before adding link