Many thanks, Tamas!
> Message: 6 > Date: Thu, 15 Jan 2015 21:46:31 +0100 > From: Tamas Nepusz <[email protected]> > To: Help for igraph users <[email protected]> > Subject: Re: [igraph] igraph-help Digest, Vol 102, Issue 13 > Message-ID: <[email protected]> > Content-Type: text/plain; charset=utf-8 > > 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 > > >>> > > > > > >
_______________________________________________ igraph-help mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/igraph-help
