Hi,

On Sep 11, 2009, at 8:22 AM, Arber Ngjela wrote:

Hello,
I am working with graph and adjacency matrix, the package 'graph' seems to be appropriate for this.
An example in the package
mat <- rbind(c(0, 0, 1, 1),
+              c(0, 0, 1, 1),
+              c(1, 1, 0, 1),
+              c(1, 1, 1, 0))
rownames(mat) <- colnames(mat) <- letters[1:4]
graph1 <- new("graphAM", adjMat=mat)
graph1
A graphAM graph with undirected edges
Number of Nodes = 4
Number of Edges = 5


how can I plot the object graph1?

I haven't used the graph library, but I do use the igraph library a bit and it's quite good (highly recommended). There is a tkplot function implemented which not only plots your graph, but allows you to pull/push nodes around on the screen, select, etc (you'll need the tcl/tk stuff installed).

Like so:
library(igraph)
mat <- rbind(c(0, 0, 1, 1),
              c(0, 0, 1, 1),
              c(1, 1, 0, 1),
              c(1, 1, 1, 0))
dimnames(mat) <- list(LETTERS[1:4], LETTERS[1:4])
graph <- graph.adjacency(mat)
tkplot(graph)

(you can specify different layouts, too).

HTH,
-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to