Undirected graphs in JavaScript