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: Gábor Csárdi
Subject: Re: [igraph] Problem with C attribute handler
Date: Sat, 12 Sep 2009 10:59:15 +0200

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

Attachment: xwel_importer.c
Description: Text Data


reply via email to

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