The following would help improve performance of the provided graph impls:
- use linkedhashmaps (speeds up iterating over vertices and neighbours - important for many algorithms)
- constructors to provide initial hashmap capacities (important when creating a large number of large graphs)
- addVertex() should put an EMPTY_MAP instead of a new Map (a new Map has a capacity of 16, this can waste quite alot of memory for leaf nodes)
Log in to post a comment.