|
From: | Николай Кинаш |
Subject: | Re: [igraph] igraph-help Digest, Vol 102, Issue 15 |
Date: | Sat, 17 Jan 2015 10:23:37 +0900 |
Message: 6
Date: Thu, 15 Jan 2015 21:46:31 +0100
From: Tamas Nepusz <address@hidden>
To: Help for igraph users <address@hidden>
Subject: Re: [igraph] igraph-help Digest, Vol 102, Issue 13
Message-ID: <address@hidden>
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
> >>>
>
>
[Prev in Thread] | Current Thread | [Next in Thread] |