Add vertex properties while adding edges via add_edge_list

I'm converting a pandas dataframe to a gt graph. I can successfully add
edges with accompany attributes from the dataframe, but the network I'm
building has its own internal vertex and edge IDs that I need to be able to
reference. I can store the edge IDs when adding edges with the eprops=
argument. However, it's unclear how I can associate my vertex IDs to the
vertices. Is there an established way to do this?

The confusion I have is knowing which vertex in the gt graph I should
associate back to the vertices in my input data. I suppose I could read
through edges and compare the edge ID in the gt graph with my source data
and then assign the correct information to the source and target nodes, but
that seems inefficient. Is there something I'm missing?

My dataframe is in the format

1 3 1
1 4 2
23 15 32

Thanks for any help.

attachment.html (1.07 KB)

I assume you mean using the Graph.add_edge_list() function. In which case,
take a look at the behavior of the 'hashed' parameter. From the documentation:

    Optionally, if ``hashed == True``, the vertex values in the edge list
    are not assumed to correspond to vertex indices directly. In this case
    they will be mapped to vertex indices according to the order in which
    they are encountered, and a vertex property map with the vertex values
    is returned. If ``string_vals == True``, the algorithm assumes that the
    vertex values are strings. Otherwise, they will be assumed to be numeric
    if ``edge_list`` is a :class:`~numpy.ndarray`, or arbitrary python
    objects if it is not.

Ah, I missed that add_edge_list() returns a property map in that case. So
the property map should have my application's vertex IDs in it as long as I
use hashed=True. I'll give that a try. Thanks.

attachment.html (2.34 KB)