November 2022
Intermediate to advanced
294 pages
5h 58m
English
One of the challenges with testing data structures is to have a suitable number of test examples. We have two approaches to dealing with this: 1) include a library with a large number of instances, and 2) provide a set of generator functions. We’d ideally like to have both an atlas full of standard and example graphs and a library of graph generators.
We already have a few examples of graphs in our NativeGraph.Examples module. This library could be expanded.
As for graph generators, let’s create a simple graph generator to get a taste of what can be done.
Create a new module NativeGraph.Builder and add this random_graph/1 function:
| | def random_graph(limit) do |
| | for(n <- 1..limit, ... |
Read now
Unlock full access