Theory and algorithms for computing remoteness function of profiles on median graphs and their generalizations with special emphasis on median and antimedian subsets