igraph-help
[Top][All Lists]
Advanced

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

Re: [igraph] igraph-help Digest, Vol 102, Issue 13


From: Tamas Nepusz
Subject: Re: [igraph] igraph-help Digest, Vol 102, Issue 13
Date: Thu, 15 Jan 2015 21:46:31 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

Hello,

Ah yes, finally I understood what the real issue is here ;) Unfortunately this
is not handled by igraph; the attributes of the initial graph are lost.
However, you can copy them easily (untested, but should work with at most minor
modifications):

def attr_preserving_barabasi_generator(*args, **kwds):
    start_from = kwds.get("start_from", None)
        if start_from:
            n = start_from.vcount()
            attr_storage = dict(
                    (attr_name, start_from.vs[attr_name])
                for attr_name in start_from.vertex_attributes()
                )
        else:
            n = None
            attr_storage = None

        result = ig.Graph.Barabasi(*args, **kwds)

        if attr_storage is not None:
            for attr_name, values in attr_storage.iteritems():
                    result.vs[:n][attr_name] = values

        return result

-- 
T.


On 01/15, Николай Кинаш wrote:
> Hello.
> 
> Issue is still persists
> 
> >>> graph = ig.Graph()
> >>> graph.add_vertex()
> >>> graph.vs[0]["age"] = 55
> >>> graph.vs[0]["age"]
> 55
> >>> graph = ig.Graph.Barabasi(graph.vcount()+3, 3, power=2.5,
> start_from=graph, outpref=True)
> >>> graph.vs[0]["age"]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> KeyError: 'Attribute does not exist'
> 
> 
> 
> >>> graph = ig.Graph()
> >>> graph.add_vertex()
> >>> graph.vs[0]["age"] = 55
> >>> graph.vs[0]["age"]
> 55
> >>> g = ig.Graph.Barabasi(graph.vcount()+3, 3, power=2.5, start_from=graph,
> outpref=True)
> >>> g.vs[0]["age"]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> KeyError: 'Attribute does not exist'
> >>> graph.vs[0]["age"]
> 55
> >>>
> 
> 
> 
> > Message: 4
> > Date: Wed, 14 Jan 2015 21:36:54 +0900
> > From: ??????? ????? <address@hidden>
> > To: address@hidden
> > Subject: [igraph] Save vertex property
> > Message-ID:
> >         <
> > address@hidden>
> > Content-Type: text/plain; charset="utf-8"
> >
> > Hello
> >
> > >>> graph = ig.Graph()
> > >>> graph.add_vertex()
> > >>> graph.vs[0]["age"] = 55
> > >>> graph.vs[0]["age"]
> > 55
> > >>> graph = ig.Graph().Barabasi(graph.vcount()+3, 3, power=2.5,
> > start_from=graph, outpref=True)
> > >>> graph.vs[0]["age"]
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > KeyError: 'Attribute does not exist'
> >
> >
> > It is possible to save "age" property after ig.Graph().Barabasi ?
> >
> >
> > Thanks.
> > -------------- next part --------------
> > An HTML attachment was scrubbed...
> > URL: <
> > http://lists.nongnu.org/archive/html/igraph-help/attachments/20150114/ec7e0025/attachment.html
> > >
> >
> > ------------------------------
> >
> > Message: 5
> > Date: Wed, 14 Jan 2015 15:09:50 +0100
> > From: Tamas Nepusz <address@hidden>
> > To: Help for igraph users <address@hidden>
> > Subject: Re: [igraph] Save vertex property
> > Message-ID: <address@hidden>
> > Content-Type: text/plain; charset=us-ascii
> >
> > > >>> graph = ig.Graph().Barabasi(graph.vcount()+3, 3, power=2.5,
> > > ...   start_from=graph, outpref=True)
> > I'm quite surprised that it works at all to be honest. The correct
> > invocation
> > would be:
> >
> > ig.Graph.Barabasi(graph.vcount()+3, 3, power=2.5, ...)
> >
> > Graph.Barabasi is a class method so it must be invoked directly on the
> > Graph
> > class, not on a Graph instance. Can you repeat your code with the above
> > modification and check if the issue still persists?
> >
> > All the best,
> > T.
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > igraph-help mailing list
> > address@hidden
> > https://lists.nongnu.org/mailman/listinfo/igraph-help
> >
> >
> > End of igraph-help Digest, Vol 102, Issue 13
> > ********************************************
> >

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


-- 
T.



reply via email to

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