parses to a graph structure