Some basic graph and tree algorithms