Implementation of graph data structure