Please note that if you use SetMultimap from google-collections , you can trivially view the collection of all edges using multimap.values() . In your case, if you understand correctly, there will be no duplicates in this collection, but, unfortunately, it does not actually implement Set . To get the set, use ImmutableSet.copyOf(multimap.values()) .
And yes, if you need this as a set often, it makes sense to keep the backup Set around and keep updating it when you go.
Or you can scratch it all and use a full-featured graphics library such as JUNG .
source share