functions in preorder.R now accept matrix, Matrix, or igraph