igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] Plotting a signed and directed graph


From: Tom Backer Johnsen
Subject: Re: [igraph] Plotting a signed and directed graph
Date: Tue, 14 Apr 2009 12:26:09 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Gabor:

Your example was very nice, but when reading the graph it failed. I suspect the error is in read.graph, but as far as I can see from the documentation, there are no arguments to tell the function that the graph is signe either. I used the following commands in R:

library(igraph)
g <- read.graph (file="First.net", format="pajek")
g <- as.directed (g)
E(g)$curved <- is.mutual(g)
# -1 edges are dashed
E(g)$lty <- ifelse( E(g)$sign > 0, 1, 2)
# A nice layout
coords <- layout.fruchterman.reingold(g)
plot(g, layout=coords)

And the First.net file looks like this:

*NETWORK First.net; 14.04.2009 / 09:46:56
*Vertices 10
1 "S65"
2 "S29"
3 "S04"
4 "S75"
5 "S24"
6 "S81"
7 "S51"
8 "S78"
9 "S86"
10 "S39"
*Matrix
 0 0 0 0 0 1 0 0 0 -1
 0 0 1 1 0 1 1 0 1 0
 -1 0 0 1 0 0 1 0 1 0
 -1 1 0 0 1 1 1 0 1 0
 0 1 0 1 0 0 0 0 -1 -1
 1 -1 0 0 0 0 0 1 0 0
 0 -1 1 1 0 -1 0 0 1 0
 0 0 1 1 0 1 -1 0 1 1
 0 0 0 0 0 0 0 0 0 -1
 1 1 1 1 1 1 1 1 1 0

Tom


Tom Backer Johnsen wrote:
Thanks for the detailed response!  And fast as well.  I'll look into it.

Tom

Gábor Csárdi wrote:
Tom,

it is possible, with 0.5.2 or later versions. (Because of the curved
edges.) 0.5.2 will be on CRAN at any time, in the meanwhile it is
here:

http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.5.2.tar.gz
http://cneurocvs.rmki.kfki.hu/igraph/download/igraph_0.5.2.zip

The latter is for windows. Here is how to do it:

library(igraph)

# just to always get the same nice picture
set.seed(123)

# a small directed random graph to test
g <- random.graph.game(10, 20, type="gnm", directed=TRUE)

# signs are random, too
E(g)$sign <- sample( c(-1,1), ecount(g), replace=TRUE)

# mutual edges are curved
E(g)$curved <- is.mutual(g)

# -1 edges are dashed
E(g)$lty <- ifelse( E(g)$sign > 0, 1, 2)

# A nice layout
coords <- layout.fruchterman.reingold(g)

# And the plot
plot(g, layout=coords)

Best,
Gabor

On Tue, Apr 14, 2009 at 10:43 AM, Tom Backer Johnsen
<address@hidden> wrote:
Gentlepersons:

I would like to obtain a plot of a signed and directed graph. The graph is small, 10 nodes or vertices. Since the graph is directed, I would like to have a curved arrow if there are arcs in both directions, with continuous leines and dashed for the negative ones. After reading the graph (containing -1's zeroes, and +1's) I see that I can plot a directed graph using g <- as
directed (g) and then plot (g).

Is this possible?

Tom



_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help








--
+----------------------------------------------------------------+
| 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 : address@hidden    URL : http://www.galton.uib.no/ |
+----------------------------------------------------------------+





reply via email to

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