# Reading graphs along with edge attributes with the C library

**URL:** <https://igraph.discourse.group/t/reading-graphs-along-with-edge-attributes-with-the-c-library/819>\
**Category:** Usage\
**Tags:** C\
**Created:** [23 August 2021 15:54 UTC](https://igraph.discourse.group/t/reading-graphs-along-with-edge-attributes-with-the-c-library/819 "2021-08-23T15:54:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecopeng](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/ecopeng/32/441_2.png) [@ecopeng](https://igraph.discourse.group/u/ecopeng)\
**Post date:** [23 August 2021 15:54 UTC](https://igraph.discourse.group/t/reading-graphs-along-with-edge-attributes-with-the-c-library/819/1 "2021-08-23T15:54:31Z")

</div>

Has anyone experienced reading graphs together with attributes (e.g. edge weights) stored in graphml files with the C library? It seems ‘igraph\_read\_graph\_graphml’ just ignores attributes. BTW, does the C library allow one to get the weighted adjacent matrix from a weighted graph (it seems ‘igraph\_get\_adjacency’ does not enable this)?

---

<div class="post-metadata">

**Author:** ![szhorvat](https://yyz2.discourse-cdn.com/free1/user_avatar/igraph.discourse.group/szhorvat/32/3_2.png) [@szhorvat](https://igraph.discourse.group/u/szhorvat)\
**Post date:** [23 August 2021 16:01 UTC](https://igraph.discourse.group/t/reading-graphs-along-with-edge-attributes-with-the-c-library/819/2 "2021-08-23T16:01:18Z")

</div>

I have tried none of this, but:

- I believe you need to set up the C attribute handler first, see [igraph Reference Manual](https://igraph.org/c/doc/igraph-Attributes.html#accessing-attributes-from-c)
- I think you will need to write your own function to convert to a weighted adjacency matrix. Take a look at [EANV](https://igraph.org/c/doc/igraph-Attributes.html#EANV) to get edge attributes, and [get\_edgelist](https://igraph.org/c/doc/igraph-Structural.html#igraph_get_edgelist) to get a vector with pairs of edge endpoints. Handling graphs with multi-edges is up to you. Use [has\_multiple](https://igraph.org/c/doc/igraph-Structural.html#igraph_has_multiple) to detect such graphs.
