Skip to content
Ed Scheinerman edited this page Oct 3, 2022 · 18 revisions

Cache

Attached to every UndirectedGraph is a data structure, called the cache, holding additional information about the graph. Typically, the cache holds the results of expensive operations, but also other items such as the name of the graph and its embedding.

Any modification to a graph completely erases the contents of its cache (because the results of any calculation are no longer valid for this graph). The function cache_clear(G) will also clear the cache.

Generally, the user will have no reason to access the cache directly, but it's simply a field in the UndirectedGraph type. For example:

julia> G = Dodecahedron()
Dodecahedron (n=20, m=30)

julia> diam(G)
5

julia> G.cache
Dict{Symbol, Any} with 10 entries:
  :vsize          => 6
  :xy             => Dict(5=>[0.348581, 0.47978], 16=>[-5.50443e-16, -0.593041]…
  :RotationSystem => Dict{Int64, RingLists.RingList{Int64}}(5=>[ 4 → 18 → 6 → 4…
  :vcolor         => Dict{Int64, Any}(5=>:white, 16=>:white, 20=>:white, 12=>:w…
  :components     => Set(Set{Int64}[Set([5, 16, 20, 12, 8, 17, 1, 19, 6, 11, 9,…
  :line_color     => :black
  :name           => "Dodecahedron"
  :dist           => Dict((11, 17)=>3, (16, 14)=>2, (18, 16)=>2, (17, 12)=>2, (…
  :diam           => 5
  :num_components => 1

Note: To avoid copying data, when a mutable result is returned via the cache mechanism, the user should not modify that result because it will modify the value stored in the cache.

Clone this wiki locally