Access underlying graph from Vertex or Edge
It would be nice if one could access the underlying graph from Vertex
/Edge
context.
The primary motivation is that in order to set a property of a vertex/edge, you need to do it through Graph.vertex_properties
/Graph.edge_properties
, thus needing the Graph
object itself.
I don't know the implementation details of graph-tool
, but I can see that internally, there is some kind of access to the underlying graph from Vertex
/Edge
context:
>>> import graph_tool.all as gt
>>> g = gt.Graph()
>>> v1 = g.add_vertex()
>>> e1 = g.add_edge(v1,v1)
>>> v1.is_valid()
True
>>> e1.is_valid()
True
>>> del g
>>> v1.is_valid()
False
>>> e1.is_valid()
False