Some algorithms derived from graph theory