[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] Import edgelist with isolates
From: |
Tamás Nepusz |
Subject: |
Re: [igraph] Import edgelist with isolates |
Date: |
Fri, 17 May 2013 13:24:26 +0200 |
Hi,
> My matrix el looks like this
> V1 V2
> 12345 29999
> 29999 34567
> 76543 NA
>
> [...]
> After having got that error I tried to replace the NAs with the same vertix
> id, so that I would get an edge like 1234 1234
> However, this results in loop-edges and not isolates.
You can get rid of the loop edges using simplify(g, remove.multiple=FALSE,
remove.loops=TRUE) -- this will probably achieve what you want. However, note
that vertices in igraph are numbered continuously from 1 in the R interface, so
if your matrix contains the three rows above, then you will end up with 76543
vertices. If this is not what you want, you can use graph.data.frame instead
which will treat the vertex names in the data frame as *symbolic* names. In
this case, igraph will make up the vertex IDs as it goes and the corresponding
names will be stored in the "name" vertex attribute.
Best,
Tamas