Replace janky string parsing with strcutured representation of graph