igraph-help
[Top][All Lists]
Advanced

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

[igraph] How to colour individual nodes in a graph


From: Gaurav Kumar
Subject: [igraph] How to colour individual nodes in a graph
Date: Tue, 9 Mar 2010 12:35:18 +0530 (IST)

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


g <- read.graph("graph.txt",format='ncol',directed=F)

nodes <- V(g)$name

colour <- read.table(“colour.txt”,header=F,sep='\t')


for (node in nodes){

  neighbour <- V(g)[nei(which(V(g)$name==node)-1)]

  for (name_id in neighbour$name){

   for(k in length(colour$V1){

   

    if(as.numeric(colour$V1[k]) == as.numeric(name_id)){

        #assign the colour to  node.

     }

   }

  }

}


Thanks for any  help or suggestion in this regards. I've noticed that the if condition is not working.


Gaurav Kumar
www.gauravkumar.org

PhD Student, Chemistry and Biomolecular Sciences, Macquarie , Sydney, Australia.
MS (Computational Biology), NCBS-TIFR, Bangalore, India.


reply via email to

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