Sorry for not posting sample data,
however I have found the problem: for some reason, igraph ignored zeros in the matrix. There were four zeros, which resulted in two missing pairs.
When I increase the ids of vertices by one from (0 to 2403) to (1 to 2404), it works.
Plus you were right, that putting not transposed matrix as edgelist just took it as a vector
Thanks,
Zbynek
however I have found the problem: for some reason, igraph ignored zeros in the matrix. There were four zeros, which resulted in two missing pairs.
When I increase the ids of vertices by one from (0 to 2403) to (1 to 2404), it works.
Plus you were right, that putting not transposed matrix as edgelist just took it as a vector
Thanks,
Zbynek
[email protected] napsal(a): -----
Komu: Help for igraph users <[email protected]>
Od: Gábor Csárdi
Odesílatel: [email protected]
Datum: 12.7.2013 15:24
Předmět: Re: [igraph] edges "disapear", when creating graph in R
Od: Gábor Csárdi
Odesílatel: [email protected]
Datum: 12.7.2013 15:24
Předmět: Re: [igraph] edges "disapear", when creating graph in R
On Fri, Jul 12, 2013 at 8:23 AM, <[email protected]> wrote:
Hello,I have encountered following problem in R:I construct graph from a matrix of edges, but resulting graph has fewer edges than there is rows in the matrix.# edges are stored in a matrix M> head(M)USEK1 USEK2
[1,] 985 866
[2,] 982 866
[3,] 1062 1039
[4,] 1088 1119
[5,] 1061 1088
[6,] 1060 1061# matrix stores 3244 edges> dim(M)[1] 3244 2# number of vertices> max(M)+1[1] 2404> g <- graph.empty(n=max(M)+1,directed=T)> g <- add.edges(g,M)
Aer you sure this works? I think it'll just take the matrix as a vector, column-wise, which is probably not what you want.
> gIGRAPH D--- 2404 3242 --#########there are two edges missing.Can anyone explain, what it the source of this behavior, and how can I fix it?
Maybe you have NAs in the matrix and they are ignored. But this is just a guess, as you did not provide a reproducible example that I could try. Maybe it is a bug in igraph, although I would say that is unlikely.
Best,
Gabor
Best Regards,
Zbynek Janoska
Transport Research CentreOlomouc, Czech Republic
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help
igraph-help mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/igraph-help
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
