finished graph and trie implementation