Adding many vertex properties with graph-tool in Python

Viewed 18

I have several features to add to each vertex in my graph. The way I know of adding vertex properties to a graph is the following:

g = Graph()
g.set_directed(False)

vprop_feature_name = g.new_vertex_property("int")
g.vp.feature_name = vprop_feature_name

Then you could associate data to the vertices by

for data in feature:
    v = g.add_vertex()
    g.vp.feature_name[v] = data

However, if I had many features, it would be quite laborious to manually code new variables vprop_feature_name for each feature. How could I automatically add features without manually creating new variable names?

0 Answers
Related