graph_to_alphabet is now an independent function