partial work towards impl of the algo to calculate the graph data structure