Perform timing comparison between different kinds of heaps as well as with equivalent igraph routine distances. To do this, a random sub-graph containing a defined number of vertices is first selected. Alternatively, this random sub-graph can be pre-generated with the dodgr_sample function and passed directly.

compare_heaps(graph, nverts = 100, replications = 2)

Arguments

graph

data.frame object representing the network graph (or a sub-sample selected with codedodgr_sample)

nverts

Number of vertices used to generate random sub-graph. If a non-numeric value is given, the whole graph will be used.

replications

Number of replications to be used in comparison

Value

Result of rbenchmark::benchmark comparison in data.frame form.

Note

igraph caches intermediate results of graph processing, so the igraph comparisons will be faster on subsequent runs. To obtain fair comparisons, run only once or re-start the current R session.

Examples

graph <- weight_streetnet (hampi) compare_heaps (graph, nverts = 1000, replications = 1)
#> test #> 6 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "BHeap") #> 7 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "FHeap") #> 11 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "set") #> 9 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "TriHeapExt") #> 10 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "Heap23") #> 8 d <- dodgr_dists(graph_contracted, from = from_id, to = to_id, heap = "TriHeap") #> 12 d <- igraph::distances(igr, v = from_id, to = to_id, mode = "out") #> 1 d <- dodgr_dists(graph, from = from_id, to = to_id, heap = "BHeap") #> 2 d <- dodgr_dists(graph, from = from_id, to = to_id, heap = "FHeap") #> 3 d <- dodgr_dists(graph, from = from_id, to = to_id, heap = "TriHeap") #> 5 d <- dodgr_dists(graph, from = from_id, to = to_id, heap = "Heap23") #> 4 d <- dodgr_dists(graph, from = from_id, to = to_id, heap = "TriHeapExt") #> replications elapsed relative user.self sys.self user.child sys.child #> 6 1 0.006 1.000 0.008 0 0 0 #> 7 1 0.006 1.000 0.012 0 0 0 #> 11 1 0.006 1.000 0.008 0 0 0 #> 9 1 0.007 1.167 0.008 0 0 0 #> 10 1 0.007 1.167 0.012 0 0 0 #> 8 1 0.008 1.333 0.008 0 0 0 #> 12 1 0.015 2.500 0.016 0 0 0 #> 1 1 0.026 4.333 0.044 0 0 0 #> 2 1 0.033 5.500 0.060 0 0 0 #> 3 1 0.035 5.833 0.060 0 0 0 #> 5 1 0.035 5.833 0.064 0 0 0 #> 4 1 0.036 6.000 0.040 0 0 0