Graphs are represented by
immutable.Graph has no persistent representation yet.
In terms of the Big-O notation, operation costs on graphs can be summarized as follows:
|addition or removal of a single element||
|bulk addition or removal of n elements||
|path search in connected graph||
|shortest path search in connected graph||
All algorithms are tail recursive, so they are guaranteed not to cause any stack overflow however big your graph is.
Like with all Scala collections, it is thread safe to use the mutable variant in the following situations:
In any of the above use cases, you are recommended using
When using the immutable implementation, try to minimize CPU usage:
Graph.from. This is because it is optimized for populating the Graph with all the elements passed. It would be far less efficient to add elements by calling