グラフの頂点ごとに、特定の条件 (「ACondition」など) が何回満たされるかをカウントする必要があります。そのためには、頂点プロパティを明示的にゼロに初期化する必要があります。以下のコードを参照してください。
# Instantiates the graph object and the vertex property.
import graph_tool.all as gt
g1 = gt.Graph()
g1.vp.AProperty = g1.new_vertex_property("int32_t")
# Sets the vertex property to zero (prior to counting).
for v1 in g1.vertices():
g1.vp.AProperty[v1] = 0
# Counts the number of times "ACondition" is satisfied for each vertex.
for v1 in g1.vertices():
if(ACondition == True):
g1.vp.AProperty[v1] += 1
初期値を明示的に設定する必要がないように、プロパティのデフォルト値を指定する方法はありますか (つまり、上記のコードの 2 番目のブロック)。