igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] sample_grg in 3D


From: seema aswani
Subject: Re: [igraph] sample_grg in 3D
Date: Tue, 31 May 2016 19:52:16 +0530

Hi Tamas,

I have tried out one code to make geometric graphs in 3D. Below is my R script.

###
get.dist = function(x)
{
  sqrt(x[1]^2 + x[2]^2)
}

get.pairs = function(N)
{
  M = matrix(0, nrow = N * (N - 1)/2, ncol = 2)
  x = 1:N
  k = 1
  
  for (i in head(x, -1))
  {
    for (j in (i + 1):(length(x)))
    {
      M[k, ] = c(i, j)
      k = k +1
    }
  }
  M
}

create.graph = function(N = 100, d = 0.3)
{
  rnd.points = matrix(runif(3 * N), ncol = 3)
  perms = get.pairs(N)
  
  Edges = apply(perms, 1, FUN = function(x){
    vec.diff = rnd.points[x[1], ] - rnd.points[x[2], ]
    get.dist(vec.diff)
  })
  
  res = cbind(Edges, perms)
  colnames(res) = c('E', 'V1', 'V2')
  list(M = res, N = N, d = d, pts = rnd.points)  
}

After achieving M with all the with associated distance value i will fetch only those values which are less than or equal to provided threshold. Is it a proper way of doing it.?

On Tue, May 31, 2016 at 7:45 PM, Tamas Nepusz <address@hidden> wrote:
Hi,

No, there is no such function; you need to code it yourself.

T.


On Tue, May 31, 2016 at 4:07 PM, seema aswani <address@hidden> wrote:
> Hi all,
>
> I want to generate geometric random graphs in 3D. Is there any in igraph to
> generate random geometric graphs in 3D..?? Please help.
>
>
> Seema
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
>

_______________________________________________
igraph-help mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/igraph-help


reply via email to

[Prev in Thread] Current Thread [Next in Thread]