News for hackers. Stuff that matters.
Re:Let’s sunset C/C++ by cousin_it on Friday August 14, 2015 @09:02AM (#10059871)
It seems to me that an undirected graph can be represented as a map from keys to sets of keys (which can be integers, strings, or anything else), with the invariant that map[x] contains y iff map[y] contains x. For a directed graph, use two maps for incoming and outgoing, with the invariant that incoming[x] contains y iff outgoing[y] contains x.

This approach doesn't require unsafe anywhere and all graph operations are easy to implement, including deleting nodes. Am I missing something?

There are no comments on this comment yet.