[Top][All Lists]

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

Re: [igraph] add vertex and set its attribute

From: Simone Gabbriellini
Subject: Re: [igraph] add vertex and set its attribute
Date: Tue, 18 Jan 2011 15:35:07 +0100

thanks Tamas,

it works perfectly! May I ask a last t one last thing, how can I find the 
vcount() for each set? I am trying something like:


but I'm afraid this is neither the right nor the smartest way... 

best regards,

Il giorno 18/gen/2011, alle ore 14.12, Tamas Nepusz ha scritto:

>> Is there a single line  code I can use for this or should I recover the 
>> vertex by its id, which I suppose will be the larger in the graph?
> THe ID of the newly added vertex should  be the largest in the graph,
> so you can use that. Alternatively, you can create a helper method:
> def add_vertex_with_attrs(graph, attrs):
>    n = graph.vcount()
>    graph.add_vertices(1)
>    for key, value in attrs.iteritems():
>        graph.vs[n][key] = value
> Then you can simply call:
> add_vertex_with_attrs(graph, {"type": 0})
> -- 
> Tamas
> _______________________________________________
> igraph-help mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/igraph-help

reply via email to

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