[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [igraph] How to identify negative vertices in graph
From: |
Frederik Elwert |
Subject: |
Re: [igraph] How to identify negative vertices in graph |
Date: |
Thu, 14 Nov 2013 17:22:59 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 |
Hello!
I had the same error. It turned out that my graph was not actually
bipartite: I had one erroneous edge that connected vertices of the same
type. Maybe that is also the case for your graph? You can check with
`is.bipartite(graph)`.
I found the wrong edge with a quick-and-dirty test:
for (v in V(G)) {
vtype <- V(G)[v]$type
for (n in neighbors(G, v)) {
if (V(G)[n]$type == vtype) {
print(paste('Problem with', V(G)[v]$label, 'and', V(G)[n]$label))
}
}
}
(There is surely a better way to test that.)
Maybe igraph should check before it tries the projection, and give a
more informative message if the graph is not bipartite?
Regards
Frederik
Am Do 14 Nov 2013 04:27:09 CET schrieb address@hidden:
> Great!
>
> Should I email it to you?
>
>
> Il 14.11.2013 03:10 Gábor Csárdi ha scritto:
>> Internal igraph vertex ids start from 0 in C, and from 1 in R, and
>> they are never negative. The not very helpful error message is coming
>> from the igraph C library and is a consequence of some other error,
>> probably in the R package, or maybe a bug in igraph.
>>
>> Your data is not very big, actually, so if you save it with save() and
>> send it to me with the complete code that you used, I can probably
>> help you. Assuming you are allowed to share the data.
>>
>> Gabor
>>
>> On Wed, Nov 13, 2013 at 9:59 PM, <address@hidden> wrote:
>>> I have a problem with the function bipartite.projection() which returns
>>>
>>> Error in bipartite.projection(igraph_bi) :
>>> At structure_generators.c:84 : Invalid (negative) vertex id, Invalid
>>> vertex id
>>>
>>> when trying to project my bipartite graph.
>>>
>>> Unfortunately my graph is very large (IGRAPH DN-B 154626 448387 -- )
>>> so I
>>> can't easily reproduce the error in a minimum working example to share.
>>>
>>> What I tried to do was to have a look at the dataframes that I used to
>>> create the graph object in the first place with
>>>
>>> graph.data.frame(edges, directed=TRUE, vertices=nodes)
>>>
>>> I checked the "id" column of my "nodes" df along with the "from"
>>> column of
>>> my "edges" df for negative values. (By the way, both "id" and "from"
>>> columns
>>> are character vectors, not numeric). Indeed I found 25 "negative"
>>> strings in
>>> my "id" column of the "nodes" df--it depends on the first character,
>>> non-alphanumerics make for a negative value of the string. But still
>>> after
>>> removing all the negative strings, and after double-checking again
>>> both "id"
>>> and "from" columns, I keep getting the same error from
>>> bipartite.projection()
>>>
>>> Error in bipartite.projection(igraph_bi) :
>>> At structure_generators.c:84 : Invalid (negative) vertex id, Invalid
>>> vertex id
>>>
>>> Now my problem is to understand how to find where the negative
>>> values that
>>> trigger the error are hidden.
>>>
>>> Is the value of the column "id" used as id of the node without any
>>> transformation (and same for the column "from" for edges) by the
>>> function
>>> graph.data.frame?
>>>
>>> How can I get the id values out of the graph object to check for
>>> negative
>>> values?
>>>
>>> _______________________________________________
>>> igraph-help mailing list
>>> address@hidden
>>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/igraph-help
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help