Hi James,
Try the following code and see if it works:
var pageType = DataClassInfoProvider.GetDataClassInfo("custom.PageTypeName");
var pagesField = new DataDefinition(pageType.ClassFormDefinition)
.GetFields<FieldInfo>()
.FirstOrDefault(x => x.Name == "YourPagesFieldName");
var relationshipName = RelationshipNameInfoProvider.GetAdHocRelationshipNameCodeName("custom.PageTypeName", pagesField);
var relationshipNameInfo = RelationshipNameInfo.Provider.Get(relationshipName);
RelationshipInfo.Provider.Add(currentPageNodeId, newRelatedPageNodeId, relationshipNameInfo.RelationshipNameId);