Graph functins and quickselect for fining median