igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] GraphML RuntimeWarning


From: Bradford Boyle
Subject: Re: [igraph] GraphML RuntimeWarning
Date: Tue, 2 Sep 2014 17:08:10 -0400

Thanks for the description of the cause. I figured this was known and
harmless, I just wanted to double check.

As for removing it from future releases to avoid confusion: if it
truly is a harmless idiosyncrasy of how igraph reads/writes GraphML,
then I think removing it would be appropriate (a la principle of least
surprise). On the other hand, might there exist a corner case where a
user loads a GraphML file into python-igraph, but the resulting graph
object is not what they were expecting because of this silently
ignoring double `id` attributes? If so, then the onus should be on the
user to catch and handle this warning (explicit is better than
implicit, errors should never pass silently). I'm not familiar enough
with the GraphML specification to know if such a corner case might
exist. Just my two cents.

Bradford


On Tue, Sep 2, 2014 at 4:57 AM, Tamás Nepusz <address@hidden> wrote:
>
> You are correct, the warning originates from the C core and it is harmless. 
> The reason is as follows. <node> tags in GraphML have an id attribute. Users 
> generally expect this attribute to be imported into an igraph vertex 
> attribute, so we do that. However, when the GraphML file is saved, this 
> vertex attribute is also written into the file as an "ordinary" GraphML node 
> attribute (not into the <node> tag but as a separate <data> subtag). We 
> cannot use the "id" vertex attribute directly in the GraphML file as the ids 
> of the <node> tags because the uniqueness of the "id" vertex attribute in 
> igraph is not guaranteed. So, the saved file has both a <node id="..."> 
> identifier for each vertex (used within the file only) and an "id" attribute 
> in a <data> subtag. That's why you get this warning, but as I said, it is 
> harmless. Actually, since it is causing confusion, it might be a good idea to 
> remove it from future releases. Any thoughts?
>
> T.
>
> > On 2 Sep 2014, at 10:23, Gianluca Della Vedova <address@hidden> wrote:
> >
> > I can confirm that I have the same warning, but using the C interface.
> > It seems that it is not a problem, as the file is read correctly.
> >
> > Best,
> >
> >> On 01/09/2014 22:09, Bradford Boyle wrote:
> >> When I try to read GraphML files written with python-igraph, I get the
> >> following `RuntimeWarning`:
> >>
> >>    RuntimeWarning: Could not add vertex ids, there is already an 'id'
> >> vertex attribute at foreign-graphml.c:416
> >>
> >> For example, consider the following simple [GraphML file][1]:
> >>
> >>    <?xml version="1.0" encoding="UTF-8"?>
> >>    <graphml xmlns="http://graphml.graphdrawing.org/xmlns";
> >>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
> >>        xsi:schemaLocation="http://graphml.graphdrawing.org/xmlns
> >>        http://graphml.graphdrawing.org/xmlns/1.0/graphml.xsd";>
> >>        <graph id="G" edgedefault="undirected">
> >>            <node id="n0"/>
> >>            <node id="n1"/>
> >>            <edge id="e1" source="n0" target="n1"/>
> >>        </graph>
> >>    </graphml>
> >>
> >> and a simple python script:
> >>
> >>    import igraph
> >>
> >>    G1 = igraph.Graph.Read_GraphML('wiki.graphml')
> >>    G1.write_graphml('wiki-ig.graphml')
> >>    G2 = igraph.Graph.Read_GraphML('wiki-ig.graphml')
> >>
> >> which loads the original GraphML files, saves it to a new GraphML file, and
> >> then tries to read back the just written file. Note the `RuntimeWarning` is
> >> only generated on the second `Read_GraphML()`. Am I using `write_graphml()`
> >> and/or `Read_GraphML()` incorrectly?
> >>
> >> For reference, I am running Ubuntu 14.04 with python-igraph 0.7 from PyPI.
> >>
> >> Thanks,
> >>
> >> Bradford
> >>
> >>
> >> [1]: http://en.wikipedia.org/wiki/GraphML#Introduction_to_GraphML
> >>
> >>
> >>
> >> _______________________________________________
> >> igraph-help mailing list
> >> address@hidden
> >> https://lists.nongnu.org/mailman/listinfo/igraph-help
> >
> > --
> > Gianluca Della Vedova
> > http://gianluca.dellavedova.org
> >
> > _______________________________________________
> > 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



reply via email to

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