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