Theory and algorithms on the median graph : application to graph-based classification and clustering