Simple javascript implementation of graphs