Coverts data format into adjecency list