I often find myself fumbling around in an attempt to connect everything in my life. Every idea that I encounter seems so far until it is connected to something in my life that I feel familiar to.
Tree of Life is an attempt to organize everything in my life in the form of a graph, more specifically, a tree. In essence, it’s a tool that produces something like this:
One important question that I had to answer was “What’s the root node?” What is in the core of my life that can serve as a root?
Inspired by Naval Ravikant and Joe Rogan’s talk, I decided to simplify my life with one word: “health”. Simply put, health is what keeps me alive, making it a fitting term for “root of life”.
Technical Implementation
In essence, what Tree of Life does is transform loosely structured text into a graph using graphviz
. Its very easy to visualize a python dictionary as a tree in graphviz but I didn’t want to ideate and organize my life while typing colons, quotes, and commas. So, I just ask GPT-4 to transform this:
Into this:
I know I don’t need GPT for this and that I can do this using code but I didn’t want to worry about me breaking textual structure and crashing my program while thinking about my life.
After using ast.literal_eval
to turn it into a python dictionary, I can turn the dictionary into a tree with a function like this:
def visualize_tree(tree, root):
dot = Digraph(comment='Tree Visualization')
dot.attr(rankdir='TB', ranksep='2.0', nodesep='0.5')
dot.attr('node', fontsize='20', width='0.5', height='0.5')
def add_nodes_edges(tree, node):
for child in tree.get(node, []):
dot.node(child, child)
dot.edge(node, child)
add_nodes_edges(tree, child)
dot.node(root, root)
add_nodes_edges(tree, root)
return dot
After this (tree is a python dict), I get a graph in both .pdf
and .gv!
tree_visual = visualize_tree(tree, 'Health')
tree_visual.view()
Reflection
This program has a lot more use cases than just for graphing your life, everything can be represented as a graph. Any and everything in this world can be represented in relation to something else and only makes sense as a relation to another thing; that is why it’s hard for you to learn calculus without knowing arithmetic, because there’s no relational foundation.
I’m putting effort into learning concepts by comparing & contrasting to other ideas, rather than attaching words and definitions to them. Again, definitions are also learning through relationship (relationship between thoughts and language) but it requires more memory in your brain than a simple idea or abstraction.