add node name (vertice attribute) as edge attribute in a directed grah (from and to)


I want that each edge in my directed graph contains 3 attributes:

  1. weight of the edge : it’s okay
  2. from node: ?
  3. to node: ?

For both (2) and (3), I want to know from which node it is to which node is goes. ( the edge attribute should be the name of the node (it is a vertice attribute that is implemented (for instance customer_ID)).

Could any of you help me?

Thank you in advance.

for edge in
     edge["from"] = edge.source_vertex["customer_ID"]
     edge["to"] = edge.target_vertex["customer_ID"]

I don’t know if that’s the best practice, but at least it works.
This does not stay updated if you add edges.