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) > graph1A graphAM graph with undirected edges Number of Nodes = 4 Number of Edges = 5 how can I plot the object graph1? Thanks in advance Arber [[alternative HTML version deleted]]
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
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?Hi Arber Rgraphviz http://bioconductor.org/packages/2.4/bioc/html/Rgraphviz.html is one option; it can be tricky to install on Windows / Mac where the version of graphviz installed on your system needs to be the same as the version used to build the package. See the README file in the package source distribution http://bioconductor.org/packages/2.4/bioc/src/contrib/Rgraphviz_1.22.1.tar.gz Martin> > Thanks in advance > > Arber > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.