automatically create adjacency list model and traverse on data input