Compilation of algorithm-specific graph states for quantum circuits