igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Writing Pajek and graphml files


From: Thomas Barnum
Subject: Re: [igraph] Writing Pajek and graphml files
Date: Mon, 25 Mar 2013 19:53:30 -0700

Hello Tamas,
Thank you for the suggestion. Your solution worked beautifully.
Very best,
Tom

On Mon, Mar 25, 2013 at 12:14 PM, Tamás Nepusz <address@hidden> wrote:
> Thank you for your reply. You are right about the graphml files having attributes set differently for R and gephi. When I look at the graphml file produced by R, the color of the edges are coded on a single line. For gephi, the file needs to have the information spread over three lines, one for R,G, and B respectively.
Well, the thing is that GraphML does not specify how the colors should be stored; in fact, the GraphML format is totally ignorant of the visual representation of the graph. Gephi *happens* to store the colors in vertex and edge attributes named "r", "g" and "b", but this is by no means part of the GraphML format at all. If you want the colors of the nodes or edges in your graph to be recognized by Gephi, you have to provide the "r", "g" and "b" attributes yourself from the R side, save the graph in GraphML format, and Gephi will parse the RGB values just fine. You may use the col2rgb function in R to convert color names to their RGB components; e.g.:

colors <- col2rgb(E(foo)$color)
E(foo)$r <- colors["red", ]
E(foo)$g <- colors["green", ]
E(foo)$b <- colors["blue", ]
write.graph(foo, format="graphml", file="test.graphml")

--
T.



reply via email to

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