Converting structure to a graph