igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] How to colour individual nodes in a graph


From: Gábor Csárdi
Subject: Re: [igraph] How to colour individual nodes in a graph
Date: Tue, 9 Mar 2010 08:18:52 +0100

On Tue, Mar 9, 2010 at 8:05 AM, Gaurav Kumar <address@hidden> wrote:
Hi,


I need some help/suggestion how to colour individual nodes in a graph. I've defined the interacting node pairs inside “graph.txt”. Sample data in graph.txt is shown below.

6000184 6005981

6000184 6022212

6000184 6032245


There is other file which contains the 11 colour code based on types of node. The sample file colour.txt looks like

6000184 green

6005981 orange

6022212 orange

6032245 orange


[...]

Hi,

I would do this:

g <- read.graph("graph.txt", format="ncol")
col <- read.table("colour.txt")
V(g)[ match( col[,1], V(g)$name )-1 ]$color <- as.character(col[,2])
print(g, v=T)

Best,
Gabor

--
Gabor Csardi <address@hidden>     UNIL DGM


reply via email to

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