igraph-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [igraph] Problem with C attribute handler


From: Juanjo Jimenez
Subject: Re: [igraph] Problem with C attribute handler
Date: Mon, 14 Sep 2009 19:05:58 -0400

Gábor, 

Don't worry about the delay. 

We compiled your code and it works fine. But we are not sure that this would solve our problem. We tested your code replacing your modification with our original function. It works fine too. Beyond the fact that we should have done something like you did to skip the line, we believe that our problem is somewhere else.

We think that the problem is in the R interface. When we load the graph from the file, we can access to the attributes from the R interpreter. But, when we pass the graph from R interpreter, apparently we don't get what we expect to get. In my first mail I explained where jumps the error. When we try to get all the vertex attributes in a vector using the macro VANV(graph,"Value", &vector) from our C function within igraph source, we get the error message I copied in my first mail. In the other hand, when we use the macro VANV in the exact same way of before, but in a C source file (for example in the file you attached in you last mail), it works perfectly.

We realized that the functions for adding vertices to a graph in rinterface.c and catrributes.c are different. The last file you attached calls the one defined in cattributes.c; while our function calls the one defined in rinterface.c.

We were wondering if our situation falls in one of these three options:
- We are missing something.
- There's a bug in the R interface.
- The implementation of the R interface assume that if you want to access to the attributes, you would do it from R and not at a lower level, hence, the implementation does not support what we intended.

Thanks!

2009/9/12 Gábor Csárdi <address@hidden>
Juanjo,

thanks for the files and sorry for the delay. The thing is, that it is
a big motivation for me if you send self-contained code, that I can
just compile and try, without having to write a lot of additional code
that possibly triggers the error.

Anyway, the problem was a bad scanf() in your code. See the C
documentation on scanf() for details. Btw. gcc (at least my version)
even gives a warning for this. If you want to skip a line, then
instead of the scanf() you should to do something like

 do {
   c=getc(instream);
 } while (c != '\n' && c != '\r');

 do {
   c = getc (instream);
 } while (isspace (c));
 ungetc (c, instream);

I have attached the corrected code, please do a diff to see the
difference. It works fine with the latest version of the 0.6 branch.

Does this solve the problem? If not, then please send me some code
that triggers the error.

Thanks,
Gabor

On Mon, Sep 7, 2009 at 6:10 PM, Juanjo Jimenez <address@hidden> wrote:
> Gábor,
>
> Thanks for the quick answer.
>
> Until last week, we were using the stable version, but we just got the
> 0.6-main branch from launchpad with bzr. Last revision is 1652, commited by
> Tamas Nepusz (fixed Makefile.am files so make dist works properly again). We
> were getting the same error with the stable version.
>
> Here I'm attaching 2 text files. The first one, is an importer for a graph
> format that we created. We call it xwel format. We put this function in
> foreign.c. The second file contains a graph in the xwel format. The format
> is very simple:
>
> *Vertices <number_of_vertices>
> id0 label0 value0
> ...
> idN labelN valueN
> *Arcs
> from0 to0 weight0
> ...
> fromM toM weightM
>
> where "fromI toJ" is an arc from idI to idJ
>
>
> Thanks again.
>
> 2009/9/7 Gábor Csárdi <address@hidden>
>>
>> Juano,
>>
>> there is too little information here to tell what is wrong. I don't
>> even know which igraph version this is. But since the C attribute
>> handler works for our (not too extensive) tests, I would say that most
>> likely there is an error in your code. But of course it is also
>> possible that this is an igraph bug.
>>
>> If you could send the code for handling the attributes from C, then
>> maybe we would be able to help you.
>>
>> Best,
>> Gabor
>>
>> On Mon, Sep 7, 2009 at 2:36 AM, Juanjo Jimenez<address@hidden>
>> wrote:
>> > We're working on a SNA project and we've been using igraph library with
>> > R.
>> > Basically, all the programming is done in C.
>> >
>> > We added an importer for a graph format defined by us. It's for directed
>> > graphs with vertex and arc attributes. Apparently, up to this point we
>> > had
>> > no trouble and all works fine. We can access to the vertex and arc
>> > attributes from the prompt in the R interpreter.
>> >
>> > Right now, we're dealing with a C function that needs to query the
>> > attributes of the vertices and arcs and we are having some problems.
>> > After building and installing, we import a graph with our importer and
>> > then
>> > when our function is called we get this message from the interpreter:
>> >
>> > At cattributes.c:753 : Unknown attribute, Invalid value
>> >
>> > In our C function we're using igraph_cattribute_VANV to get all the
>> > values
>> > of all the values of a vertex attribute. Here's where the error comes
>> > up.
>> > Debbuging our code, we ended in this function defined in cattributes.c:
>> >
>> > igraph_bool_t igraph_i_cattribute_find(const igraph_vector_ptr_t
>> > *ptrvec,
>> > const char *name, long int *idx) {
>> > long int i, n=igraph_vector_ptr_size(ptrvec);
>> > igraph_bool_t l=0;
>> >
>> > …
>> >
>> > }
>> >
>> > The variable n is a negative number after calling igraph_vector_ptr_size
>> > when should be 2.
>> >
>> > From the igraph documentation, we know this:
>> >
>> > “… There is an experimental attribute handler that can be used from C
>> > code.
>> > ...”
>> >
>> > and were wondering if our problem is related to this experimental state
>> > or
>> > is something else.
>> >
>> > Thanks and sorry about my English.
>> >
>> >
>> > _______________________________________________
>> > igraph-help mailing list
>> > address@hidden
>> > http://lists.nongnu.org/mailman/listinfo/igraph-help
>> >
>> >
>>
>>
>>
>> --
>> Gabor Csardi <address@hidden>     UNIL DGM
>>
>>
>> _______________________________________________
>> igraph-help mailing list
>> address@hidden
>> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help
>
>



--
Gabor Csardi <address@hidden>     UNIL DGM

_______________________________________________
igraph-help mailing list
address@hidden
http://lists.nongnu.org/mailman/listinfo/igraph-help



reply via email to

[Prev in Thread] Current Thread [Next in Thread]