The Erlang digraph module surprised me with a state change.
When working with other data structure modules in Erlang, for example, the sets module, an instance of the transferred data structure, is not changed. The function returns a new modified version, for example.
>S = sets:new(). >sets:size(S). 0 >T = sets:add_element(S, "element"). >sets:size(S). 0 >sets:size(T). 1
This is not a behavior when working with the digraph module.
>G = digraph:new(). >digraph:no_vertices(G). 0 >digraph:add_vertex(G, "vertex"). >digraph:no_vertices(G). 1
First, why is the digraph library different in this regard?
Secondly, and more importantly, how does the digraph add a new state to an existing binding?
I assume that the state is stored in another process that the digraph module identifies using the existing and unchanged G binding. Is that so? Or are there other ways to change state related to binding?
erlang directed-graph
John kane
source share