Hello All,

  I am working on graph object using IGRAPH package wanted to do Bonacich
Power.  This is my graph object.

The file 'Graph.RData' (4.2 MB) is available for download at
http://dropbox.unl.edu/uploads/20090424/cfe4fcb854bb17f2/Graph.RData

Graph size

Vertices: 20984
Edges: 326033
Directed: FALSE
No graph attributes.
Vertex attributes: name.
No edge attributes.

When I use bonacich power it goes out of memory

Error in get.adjacency.dense(graph, type = type, attr = attr, names =
names,  :
  At vector.pmt:409 : cannot reserve space for vector, Out of memory

I got help from IGRAPH community to use sparse Matrix

http://igraph.wikidot.com/r-recipes#toc6


bonpow.sparse <- function(graph, nodes=V(graph), loops=FALSE,
                          exponent=1, rescale=FALSE, tol=1e-07) {

  ## remove loops if requested
  if (!loops) {
    graph <- simplify(graph, remove.multiple=FALSE, remove.loops=TRUE)
  }

  ## sparse adjacency matrix
  d <- get.adjacency(graph, sparse=TRUE)

  ## sparse identity matrix
  id <- spMatrix(vcount(graph), vcount(graph),
                 i=1:vcount(graph), j=1:vcount(graph),
                 x=rep(1, vcount(graph)))
  id <- as(id, "dgCMatrix")

  ## solve it
  ev <- solve(id - exponent * d, tol=tol) %*% degree(graph, mode="out")

  if (rescale) {
    ev <- ev/sum(ev)
  } else {
    ev <- ev * sqrt(vcount(graph)/sum((ev)^2))
  }

  ev[as.numeric(nodes) + 1]
}

## test graph
test.g <- simplify(ba.game(1000,m=2))

## test run
system.time(bp1 <- bonpow(test.g))
system.time(bp2 <- bonpow.sparse(test.g))

## check that they are the same
max(abs(bp1-bp2))



I get following error and sometime it crashes.

In solve(id - exponent * d, tol = tol) :
Reached total allocation of 1535Mb: see help(memory.size).I increased the
memory size and still it is not helpful

Help on this would be great.

These are steps I followed

1. Created graph object using Igraph version 0.6 on R 2.8.1 windows XP
2. Bonpow(g)
3. Bonpow.sparse function

sessionInfo()

R version 2.8.1 (2008-12-22)
i386-pc-mingw32
locale:
LC_COLLATE=English_United States.1252;LC_CTYPE=English_United
States.1252;LC_MONETARY=English_United
States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252
attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base
other attached packages:
[1] Matrix_0.999375-23 lattice_0.17-20    igraph_0.6
loaded via a namespace (and not attached):
[1] grid_2.8.1

Thanks in advance

Nathan

	[[alternative HTML version deleted]]


