writeGP: Export/import graph.

Description Usage Arguments Details Value Examples

View source: R/writeGP.R

Description

Given a grapherator graph function writeGP saves the graph to a file. Function readGP imports a graph given a filename.

Usage

1
2
3

Arguments

graph

[grapherator]
Graph.

file

[character(1)]
Path to file where the graph shall be stored (for writeGP) or which contains the graph to be imported (for link{readGP}).

Details

Instances are stored in a format similar to the one used by Cardoso et al. in their MOST project. Note that all values in each line are separated by comma. First line contains four integer values: number of nodes n, number of edges m, number of clusters cl and number of weights p per edge. The second line contains the weight types. The third line contains the node types. The next n lines contain the node coordinates. In case of a clustered instance the next line contains the node to cluster membership mapping. The last m lines contain the following information each: i,j,w1(i,j),...,wp(i,j) I.e., each two node numbers i and j followed by the p weights of the edge (i, j).

Value

Function writeGP silently returns the passed filename file whereas writeGP returns a grapherator object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
g = graph(0, 100)
g = addNodes(g, n = 25, generator = addNodesGrid)
g = addEdges(g, generator = addEdgesGrid)
g = addWeights(g, generator = addWeightsRandom, method = runif, min = 5, max = 100, to.int = TRUE)
g = addWeights(g, generator = addWeightsRandom, method = runif, min = 10, max = 100, to.int = TRUE)
## Not run: 
filename = tempfile()
writeGP(g, file = filename)
g2 = readGP(file = filename)
unlink(filename)
do.call(gridExtra::grid.arrange, c(plot(g), plot(g2), list(nrow = 2)))

## End(Not run)

jakobbossek/grapherator documentation built on Feb. 23, 2018, 12:13 a.m.