Skip to content

Instantly share code, notes, and snippets.

View travishathaway's full-sized avatar
🐢
Taking it slow and easy

Travis Hathaway travishathaway

🐢
Taking it slow and easy
View GitHub Profile
@travishathaway
travishathaway / nested_list.py
Last active August 29, 2015 14:08
Recently, I had a problem. I only had a list of child to parent relations. I needed to create a nested list structure. This is how I did it.
import collections
def create_tree(edges):
'''
This parses the edges and creates a nested dictionary
'''
trees = collections.defaultdict(dict)