igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph-help Digest, Vol 62, Issue 3


From: Andrew Khong
Subject: Re: [igraph] igraph-help Digest, Vol 62, Issue 3
Date: Wed, 7 Sep 2011 01:08:58 +0800

Hi,

I've attached the attribute handler to igraph. I want to get the vertex color 
for all vertices in the graph iteratively. However, I get a segmentation fault.

Below are my codes.

 // attach graph attributes handler to igraph
igraph_attribute_table_t *table;
table = igraph_i_set_attribute_table(table);

FILE *instream2 = fopen(input_pajek_file, "r");

igraph_t pajek_graph;
igraph_read_graph_pajek(&pajek_graph, instream2);

igraph_vs_t vs;
igraph_vit_t vit;
igraph_vs_adj(&vs, 0, IGRAPH_ALL);
igraph_vit_create(&graph, vs, &vit);

while (!IGRAPH_VIT_END(vit))
{
        const char *node_color = igraph_cattribute_VAS(&pajek_graph, "color", 
IGRAPH_VIT_GET(vit));    <------ the error happens here.
        printf("node color = %s\n", node_color);
        IGRAPH_VIT_NEXT(vit);
}
igraph_vit_destroy(&vit);
igraph_vs_destroy(&vs);

Hope to hear from you soon.

Cheers,
Andrew

On Sep 7, 2011, at 12:00 AM, address@hidden wrote:

> Send igraph-help mailing list submissions to
>       address@hidden
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>       https://lists.nongnu.org/mailman/listinfo/igraph-help
> or, via email, send a message with subject or body 'help' to
>       address@hidden
> 
> You can reach the person managing the list at
>       address@hidden
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of igraph-help digest..."
> 
> 
> Today's Topics:
> 
>   1. Enquiry about reading Pajek file (Andrew Khong)
>   2. Re: Enquiry about reading Pajek file (Tamas Nepusz)
> 
> 
> ----------------------------------------------------------------------
> 
> Message: 1
> Date: Tue, 6 Sep 2011 01:36:54 +0800
> From: Andrew Khong <address@hidden>
> To: address@hidden
> Subject: [igraph] Enquiry about reading Pajek file
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset=us-ascii
> 
> Hi,
> 
> I need to read a Pajek .net file. From what I know, I need to install the 
> graph attribute handler first before I can call the function 
> igraph_read_graph_pajek.
> 
> Is there any example to show how to use the igraph_read_graph_pajek function 
> with the attribute handler interface?
> 
> My Pajek file includes the colour of the vertex, as well as the label of the 
> vertex.
> 
> Cheers,
> Andrew
> 
> 
> 
> 
> ------------------------------
> 
> Message: 2
> Date: Tue, 06 Sep 2011 12:02:43 +0200
> From: Tamas Nepusz <address@hidden>
> To: Help for igraph users <address@hidden>
> Subject: Re: [igraph] Enquiry about reading Pajek file
> Message-ID: <address@hidden>
> Content-Type: text/plain; charset=ISO-8859-1
> 
>> I need to read a Pajek .net file. From what I know, I need to install the 
>> graph attribute handler first before I can call the function 
>> igraph_read_graph_pajek.
> Yes, that's true.
> 
>> Is there any example to show how to use the igraph_read_graph_pajek function 
>> with the attribute handler interface?
> Nothing particular, just call igraph_read_graph_pajek as usual and the
> vertex/edge attributes will be stored by igraph automatically if the
> attribute handler is attached. I guess you know this page already:
> 
> http://igraph.sourceforge.net/doc/html/igraph_read_graph_pajek.html
> 
> The above page lists how the one-character attribute names of Pajek are
> renamed on-the-fly to more human-readable forms. For instance, vertex
> colours will be stored in the "color" vertex attribute as strings, and
> vertex labels will be stored in the "label" attribute (I guess).
> 
> To retrieve the values of a string attribute for all the vertices, you can
> simply use the macros and functions in the C attribute handler:
> 
> http://igraph.sourceforge.net/doc/html/ch09s02s01.html
> 
> E.g., igraph_cattribute_VASV or simply the VASV macro queries the value of a
> string vertex attribute for many vertices. These macro names are formed
> using the following rules:
> 
> - The first character is G for [g]raph attributes, V for [v]ertex
> attributes, E for [e]dge attributes.
> - The second character is always A (standing for [a]ttribute).
> - The third character is N for [n]umeric attributes, S for [s]tring 
> attributes.
> - The optional fourth character is V if the function/macro queries the
> attribute for more than one vertex or edge. V stands for [v]ector.
> 
> Note that the C attribute handler supports string and numeric attributes
> only, and you have to know the type of an attribute in advance to access it.
> If you want to query the attribute names/types for a particular graph, use
> igraph_cattribute_list():
> 
> http://igraph.sourceforge.net/doc/html/ch09s02s01.html#igraph_cattribute_list
> 
> Cheers,
> Tamas
> 
> 
> 
> ------------------------------
> 
> _______________________________________________
> igraph-help mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/igraph-help
> 
> 
> End of igraph-help Digest, Vol 62, Issue 3
> ******************************************




reply via email to

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