graph: Generate a bare graph.

Description Usage Arguments Value See Also Examples

View source: R/graph.R

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

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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)

jakobbossek/grapherator documentation built on Oct. 4, 2021, 11:03 a.m.