This repository has been archived by the owner on Jan 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
control.r
87 lines (69 loc) · 2.36 KB
/
control.r
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
require(Rcpp)
require(igraph)
Sys.setenv("PKG_CXXFLAGS"="-std=c++11")
sourceCpp("export.cpp")
ResetSeed <- function() {
Seed <<- 0xFA2B5E01
}
SetSeed <- function(seed) {
Seed <<- seed
}
if (!exists("Seed")) {
ResetSeed()
}
Process <- function(data, draw, use_layout, ...) {
labels <- data$labels
colors <- ifelse(data$colors, "gray75", "white")
n = length(colors)
graph <- graph(edges = data$edges + 1, n = n, directed = F)
cat("Average node degree:", ecount(graph) * 2 / n, "\n\n")
if (draw) {
ratio <- 16/9
layout <- NULL
if (use_layout) {
layout <- matrix(data$coords, ncol=2, byrow=T)
layout[, 1] <- (layout[, 1] * 2 - 1) * ratio
layout[, 2] <- layout[, 2] * 2 - 1
} else {
layout <- layout.auto(graph)
layout <- layout.norm(layout, -ratio, ratio, -1, 1) # adjusting for 16:9 display
}
plot( graph, vertex.label = labels, vertex.label.color = "black", vertex.color = colors,
layout = layout, rescale = F, ... )
}
graph
}
Random <- function(n, r_coeff, random_edges_ratio_nodes = 0,
level = 0, filter = "", label = 0, draw = T, layout = T, ...)
{
SetSeed_R(Seed)
Process(Random_R(n, r_coeff, random_edges_ratio_nodes, level, filter, label), draw, layout, ...)
}
RandomNodeDegrees <- function(n, r_coeff, random_edges_ratio_nodes = 0, max_level = 0) {
SetSeed_R(Seed)
RandomNodeDegrees_R(n, r_coeff, random_edges_ratio_nodes, max_level)
}
Manual0 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual0_R(level, filter), draw, layout)
}
Manual1 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual1_R(level, filter), draw, layout)
}
Manual2 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual2_R(level, filter), draw, layout)
}
Manual3 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual3_R(level, filter), draw, layout)
}
Manual4 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual4_R(level, filter), draw, layout)
}
Manual5 <- function(level = 0, filter = "", draw = T, layout = T) {
SetSeed_R(Seed)
Process(Manual5_R(level, filter), draw, layout)
}