The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.

Using magrittr pipes

Jakob Bossek

2017-12-20

Improving code readability

Since each generator function expects the graph object as its first argument one can make use of the fantastic magrittr pipes to improve reading. See the documentation of the magrittr package for details on the forward-pipe operator.

library(grapherator)
library(magrittr)

set.seed(1) # reproducability
g = graph(lower = 0, upper = 10) %>%
  addNodes(n = 20, generator = addNodesUniform) %>%
  addEdges(generator = addEdgesComplete) %>%
  addWeights(generator = addWeightsRandom, method = runif, min = 5, max = 10) %>%
  addWeights(generator = addWeightsRandom, method = runif, min = 5, max = 10)
print(g)
#> GRAPHERATOR GRAPH
#> #nodes           : 20 (UNG)
#> #edges           : 190 (CEG)
#> #weights per edge: 2 (RWG,RWG)
do.call(gridExtra::grid.arrange, c(plot(g), list(nrow = 1)))
Example network.

Example network.

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.