Re: [R] igraph and tkgraph

From: Gábor Csárdi <csardi.gabor_at_gmail.com>
Date: Sun, 16 Nov 2008 15:01:46 +0100

Tom,

On Fri, Nov 14, 2008 at 4:35 PM, Tom Backer Johnsen <backer_at_psych.uib.no> wrote:
> Gabor:
>
> Actually, I meant a script GUI management of ugraph I managed to locate on
> the net.

Oh, ok, it will be part of igraph from the next version. But its capabilities are very limited. We are considering writing a full-fledged GUI to igraph, but I haven't found the right tools for it yet, so this will happen only next year I think.

> Disregarding that, thank you for the suggestions. igraph is
> definitly a non-trivial affair, with a lot of options and corresponding
> flexibility. I made some changes to what you wrote:
>
> A <- matrix(sample(c(-1, 0, 0, 0, 1), 25, replace=T), 5)
> g <- graph.adjacency(A, mode="directed", weighted=T, diag=F)
> E(g)$lty <- ifelse(E(g)$weight > 0, 1, 2)
> tkplot (g, layout=layout.kamada.kawai)
>
> This gives me something that is very close to what I want, apart from a
> suspicion that if the relations between two vertices is non-symmetric, only
> one of the is shown. Is it possible to have a pair of, say slightly curved
> arrows as edges between them in that case?

Not in the 0.5.1 version, but with the coming 0.6 version this is possible. You can download a preliminary package from here: http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.6.tar.gz or if you're using windows, then I can build a windows binary package for you. Let me know if you need one.

To make the edges curved, all you need is adding 'edge.curved=TRUE' to the arguments of plot or tkplot. To make them less curved, specify a number smaller than 0.5, the bigger the number the more curved they will be.

Best,
Gabor

> Tom
>
> Gábor Csárdi wrote:
>>
>> Tom, you mean 'tkplot' in the igraph package? Look at ?igraph.plotting
>> on how to set up plotting parameters, e.g. if you want different line
>> types for the positive/negative relations, then you can make use of
>> the 'lty' parameter:
>>
>> A <- matrix(sample(c(-1,0,1), 100, replace=TRUE), 10)
>> g <- graph.adjacency(A, mode="upper", weighted=TRUE, diag=FALSE)
>> E(g)$lty <- ifelse(E(g)$weight > 0, 1, 2)
>> tkplot(g, layout=layout.kamada.kawai)
>>
>> Gabor
>>
>> On Fri, Nov 14, 2008 at 12:40 PM, Tom Backer Johnsen
>> <backer_at_psych.uib.no> wrote:
>>>
>>> I have a number of (directed) graphs based on social groups, where the
>>> members have expresed likes and dislikes in respect to the other members.
>>> tkgraph makes it simple to draw the graphs in a very pleasing way, but I
>>> would like to differentiate between positive and negative relations in
>>> the
>>> graph by having the edges for the negative relations dashed and the
>>> positive
>>> ones continuous.
>>>
>>> Is that possible? If so how?
>>>
>>> Tom
>>>
>>> ______________________________________________
>>> 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.
>>>
>>
>>
>>
>
>
> --
> +----------------------------------------------------------------+
> | Tom Backer Johnsen, Psychometrics Unit, Faculty of Psychology |
> | University of Bergen, Christies gt. 12, N-5015 Bergen, NORWAY |
> | Tel : +47-5558-9185 Fax : +47-5558-9879 |
> | Email : backer@psych.uib.no URL : http://www.galton.uib.no/ |
> +----------------------------------------------------------------+
>

-- 
Gabor Csardi <Gabor.Csardi_at_unil.ch>     UNIL DGM

______________________________________________
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.
Received on Sun 16 Nov 2008 - 14:04:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sun 16 Nov 2008 - 18:30:26 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive