partial solution to graph problem