I have a lattice that is wrapped on a torus (each nodes on the end of the graph are linked to their opposite on the grid).
require("igraph")
require("rgl")
n = 10
g = graph.lattice(c(n,n)) # create a square lattice (nxn)
plot(g,vertex.size = 0.5,vertex.size = 4,vertex.label = NA,vertex.color = "red")
# want to connect up the corners (horribly done)
v1 = seq(from =1, to = n,by = 1)
v2 = seq(from = n, to = n^2, by = n)
v3 = seq(from = n^2, to = n^2 - n+1, by = -1)
v4 = seq(from = v3[length(v3)],to = 1,by = -n)
a = cbind(rbind(v1,v2), rbind(v3,v4))
a2 = matrix(a,nrow=length(a),ncol = 1)
g = add.edges(g,a2)
plot(g,vertex.size = 4,vertex.label = NA,vertex.color = "red")
sum(degree(g2) != 4) # so all nodes do indeed have degree four, delighted!
What im having a problem creating/finding is a layout that'll plot the graph on a torus, ideally i'd also like a 3d layout for rglplot.
l2d = layout.a.lovely.torus(g,dim = 2)
l3d = layout.a.lovely.torus(g,dim = 3)
plot(g,vertex.size = 4,vertex.label = NA,vertex.color = "red",layout = l2d)
rglplot(g,vertex.size = 4,vertex.label = NA,vertex.color = "red",layout = l3d)
see figure 1, left hand graph for an example of something similar to what im looking for (also its a really nice paper!!)