addNodes {grapherator} | R Documentation |
Add nodes to graph.
Description
Places node coordinates in the two-dimensional Euclidean plane.
Usage
addNodes(graph, n, generator, coordinates = NULL, by.centers = FALSE,
skip.centers = integer(0L), par.fun = NULL, ...)
Arguments
graph |
[grapherator ]
Graph.
|
n |
[integer ]
Number of nodes to place. If by.centers is FALSE a single
integer value is expected. Otherwise, a vector v may be passed. In this case
v[i] coordinates are generated for each cluster. However, if a single value is
passed and by.center == TRUE , each cluster is assigned the same number of
nodes.
|
generator |
[function(graph, ...) ]
Function used to generate nodes. The functions needs to expect the number
of points to generate as the first argument n . Additional control argument are
possible.
|
coordinates |
[matrix(n, 2) ]
Matrix of coordinates (each row is one node/point).
Default is NULL . If this is set, setting of generator , by.centers ,
and par.fun are ignored. This parameter is handy, if one wants to add
coordinates by hand.
Default is NULL .
|
by.centers |
[logical(1) ]
Should coordinates be placed for each cluster center seperately? This enables
generation of clustered graphs.
Default is FALSE .
|
skip.centers |
[integer ]
Optional IDs of cluster centers not to consider in clustered node generation, i.e.,
if by.centers = TRUE .
Default is not to skip any cluster.
|
par.fun |
[function(cc) | NULL ]
Optional function which is applied to each cluster center before the generation
of coordinates in case by.centers is TRUE . This enables to specifically
determine additional parameters for the generator for each cluster.
|
... |
[any]
Further arguments passed down to generator .
|
Value
[grapherator
] Graph.
See Also
Other graph generators: addEdges
,
addWeights
, graph
Examples
# Clustered graph
g = graph(0, 1000)
g = addNodes(g, n = 5, generator = addNodesLHS)
g = addNodes(g, n = c(3, 10, 20, 10, 40), by.centers = TRUE, generator = addNodesUniform,
lower = c(0, 0), upper = c(30, 30))
## Not run:
plot(g, show.edges = FALSE)$pl.coords
## End(Not run)
# Mixed graph
g = graph(0, 100)
g = addNodes(g, n = 100, generator = addNodesLHS)
g = addNodes(g, n = 100, generator = addNodesGrid)
## Not run:
plot(g, show.edges = FALSE)$pl.coords
## End(Not run)
[Package
grapherator version 1.0.0
Index]