$param = array(
$productid=>array(
'position'=>0
),
$productid=>array(
'position'=>0
));
$related_product = $product->getRelatedProductCollection();
foreach($related_product as $rproduct){
$rlateproduct = Mage::getModel('catalog/product')->load($rproduct->getId());
$data[$rlateproduct->getId()] = array('position'=>0);
}
if($data != ""){
$result = $param + $data;
}
else{
$result = $param;
}
$product->setRelatedLinkData($result);
$product->save();