Convert to a graph