Direct from the API Examples:
private bool CreateRelationship()
{
// Get the relationship name
RelationshipNameInfo relationshipName = RelationshipNameInfoProvider.GetRelationshipNameInfo("MyNewRelationshipName");
if (relationshipName != null)
{
// Get the tree structure
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Get documents for relationship (the Root document is used for both in this example)
TreeNode root = tree.SelectSingleNode(SiteContext.CurrentSiteName, "/", null, true);
// Create the relationship between documents
RelationshipInfoProvider.AddRelationship(root.NodeID, root.NodeID, relationshipName.RelationshipNameId);
return true;
}
return false;
}