I did make one important update. The nodes no longer need to be integers. You can build a graph of nodes and adjacency lists without the pain of mapping to indexes. Also, the "adjacency lists" can be a provided map, or any function from node->neighbors.
(The fact that Clojure maps are functions of their keys is amazing. Why haven't other languages figured that out?) On Mon, Feb 23, 2009 at 9:50 PM, Jeffrey Straszheim < straszheimjeff...@gmail.com> wrote: > It would be easy to convert from your form to adjacency lists, so if you > want it write a converter :) I think we should keep the algorithms > *basically* efficient. I don't see that as premature optimization at all. > > > On Mon, Feb 23, 2009 at 9:37 PM, Eric <ericwnorm...@gmail.com> wrote: > >> >> >> >> On Feb 23, 6:38 pm, Jeffrey Straszheim <straszheimjeff...@gmail.com> >> wrote: >> > Well, right now I'm just handling directed graphs, and basically >> treating >> > nodes as integer indexes, with a simple formula from index to adjacency >> list >> > of nodes. >> > >> >> I would actually like to see an implementation that more closely >> resembles the mathematical representation of graphs: >> >> A graph is <V, E>, where V is a set of vertices and E is a set of >> edges <v1, v2>. >> >> It's really easy to do with maps and sets: >> >> {:V #{1 2 3 4 5} :E #{{:a 1 :b 2} . . . . >> >> It is less efficient than yours, but let's not optimize too soon. >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---