Hello,

It's more or less the same it was with vertices. If the edge labels represent weights, then create an appropriate attribute and set the labels' values to that attribute's values:

E(g)$weight <- something   # keep the weights in a separate attribute
E(g)$label <- E(g)$weight     # set when needed

The plot function now uses these edge labels.

Rui Barradas

Em 28-07-2012 17:44, Vlatka Matkovic Puljic escreveu:
Is it possible to write a numbers of link next to lines of the network?

For exmple, I have 3 trials that have studied two drugs in network.
So, now it seems all links are of same weight.





2012/7/27 Vlatka Matkovic Puljic <v.matkovic.pul...@gmail.com>

Thank you!

It works fine now! :)

  2012/7/27 Rui Barradas <ruipbarra...@sapo.pt>

Hello,

As for the directed = FALSE, it works with me:

g <- graph(given, directed = FALSE)

As for the label, it's easy. Create an attribute 'name' and then set the
label to that attribute. For instance, using the alphabet's letters, first
uppercase.

V(g)$name <- c(LETTERS, letters)[V(g)]  # or any other names
V(g)$label <- V(g)$name

Keep 'name' and 'label' separate, like this you may change the label if
needed but the name will still be there.
Then the plot functions recognise the label attribute.


Hope this helps,

Rui Barradas

Em 27-07-2012 11:37, Vlatka Matkovic Puljic escreveu:

  Thank you Rui.

With matrix works better. I got plot I have expected to have.

I want to be undirected. But

directed = FALSE
or
as.undirected(graph)

are not working? Where I'd gone wrong?

Shouldn't it be possible to add names  instead of numbers of nods with
vertex.label= ?



2012/7/26 Rui Barradas <ruipbarra...@sapo.pt>

  Hello,
I don't see the problem.

given <- scan(text="

15 2
10 4
10 4
10 4
13 4
13 4
15 4
18 4
11 5
2 6
7 6
7 6
7 6
12 6
15 6
15 6
19 6
22 6
24 6
6 7
5 12
5 12
7 12
11 12
13 12
13 12
13 12
13 12
16 12
17 12
23 12
23 12
23 12
23 12
6 13
12 13
6 14
6 15
9 15
12 15
13 15
17 16
16 17
1 18
12 18
23 18
2 19
6 19
24 19
21 22
3 25
5 26
6 27
7 27
15 29
20 30
25 31
28 31
8 32
6 33
14 33
22 34
")
mat <- matrix(given, ncol=2, byrow=TRUE)

g <- graph(given)
# Or, not run (note the transpose)
#g <- graph(t(mat))
# The edges are exactly what is given
E(g)

V(g)$label <- V(g)
g$layout <- layout.fruchterman.reingold
plot(g, edge.arrow.size=0.5, edge.loop.angle=1, edge.curved=FALSE)


So my guess is you've messed up the graph creation.
Also, don't post datasets like that, use dput(), lik this:

dput(given)
c(15, 2, 10, 4, 10, 4, 10, 4, 13, 4, 13, 4, 15, 4, 18, 4, 11,
5, 2, 6, 7, 6, 7, 6, 7, 6, 12, 6, 15, 6, 15, 6, 19, 6, 22, 6,
24, 6, 6, 7, 5, 12, 5, 12, 7, 12, 11, 12, 13, 12, 13, 12, 13,
12, 13, 12, 16, 12, 17, 12, 23, 12, 23, 12, 23, 12, 23, 12, 6,
13, 12, 13, 6, 14, 6, 15, 9, 15, 12, 15, 13, 15, 17, 16, 16,
17, 1, 18, 12, 18, 23, 18, 2, 19, 6, 19, 24, 19, 21, 22, 3, 25,
5, 26, 6, 27, 7, 27, 15, 29, 20, 30, 25, 31, 28, 31, 8, 32, 6,
33, 14, 33, 22, 34)

Now all anyone has to do is to copy that output and paste it into an R
session.
(Try it with the matrix to see the result)

Hope this helps,

Rui Barradas
Em 25-07-2012 16:27, Vlatka Matkovic Puljic escreveu:

  **Hi,

I wanted to create a network of drugs that are being studied together.
So, I created a file as a graph.
But plot of my network is not corect!
It looks like to me that something else is lying behind this network
links
created.

Could someone help me with this?

Thanx!

a<-read.graph(file=file.****choose(), format="edgelist")

plot.igraph(a)

File (number present ID of drug):

15 2
10 4
10 4
10 4
13 4
13 4
15 4
18 4
11 5
2 6
7 6
7 6
7 6
12 6
15 6
15 6
19 6
22 6
24 6
6 7
5 12
5 12
7 12
11 12
13 12
13 12
13 12
13 12
16 12
17 12
23 12
23 12
23 12
23 12
6 13
12 13
6 14
6 15
9 15
12 15
13 15
17 16
16 17
1 18
12 18
23 18
2 19
6 19
24 19
21 22
3 25
5 26
6 27
7 27
15 29
20 30
25 31
28 31
8 32
6 33
14 33
22 34





  --
**************************
Vlatka Matkovic Puljic
gsm: +32.474.894953




______________________________________________
R-help@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.

Reply via email to