graph {grapherator}R Documentation

Generate a bare graph.

Description

This function generates a bare graph object of type grapherator. The generated object does not contain nodes, edges or edge weights. It serves as a starting point for a three step approach of grapherator graph construction: 1) Add nodes respectively coordinates via addNodes, 2) add edges via addEdges and finally 3) add edge weights with the function addWeights.

Usage

graph(lower, upper)

Arguments

lower

[integer(1)]
Lower bounds for node coordinates in the Euclidean plane.

upper

[integer(1)]
Upper bounds for node coordinates in the Euclidean plane.

Value

[grapherator] Graph.

See Also

Other graph generators: addEdges, addNodes, addWeights

Examples

# complete graph with one U(10, 20) sampled weight per edge
g = graph(0, 10)
g = addNodes(g, n = 10, generator = addNodesUniform)
g = addEdges(g, generator = addEdgesComplete)
g = addWeights(g, generator = addWeightsRandom, method = runif, min = 10, max = 20)
## Not run: 
do.call(gridExtra::grid.arrange, plot(g, show.edges = FALSE))

## End(Not run)

# we extend the graph by adding another weight which is based
# on the Euclidean distance between the node coordinates
g = addWeights(g, generator = addWeightsDistance, method = "euclidean")
## Not run: 
do.call(gridExtra::grid.arrange, plot(g, show.edges = FALSE))

## End(Not run)

# next we generate a graph with each two weights per edge which resembles
# a street network. The edge weights have a positive correlation.
g = graph(0, 100)
g = addNodes(g, n = 5, generator = addNodesLHS)
g = addNodes(g, n = c(10, 10, 15, 20, 50), by.centers = TRUE,
  generator = addNodesUniform, lower = c(0, 0), upper = c(10, 10))
g = addEdges(g, generator = addEdgesDelauney, type = "intracluster")
g = addEdges(g, generator = addEdgesDelauney, type = "intercluster", k = 4L)
g = addWeights(g, generator = addWeightsCorrelated, rho = 0.6)
## Not run: 
print(g)
do.call(gridExtra::grid.arrange, plot(g, show.edges = FALSE))

## End(Not run)

[Package grapherator version 1.0.0 Index]