I'm trying to read a graph from a .txt file that has the following structure:
115564928125997351000, ah.creativecodeapps.tiempo,1
117923818995099650007, air.com.agg.popcornmakermarket,-1
104000841215686444437, air.com.zahdoo.cadie,1
.
.
.
I've been using the following command:
g=nx.read_weighted_edgelist('siatoy.txt', delimiter=',',nodetype=str,encoding='utf-8')
But when I do g.edges(data=True)
, I got this:
[('106784557494786869271', ' com.map2app.U5635321228165120A5661458385862656'),
('106784557494786869271',' com.jb.gokeyboard.theme.mzdevelopment.americankeyboard'),
('106784557494786869271', ' com.benbasha.whoopeecushion'),
(' com.airplaneflighttakeoff', '115981152169430603941'),...]
But I want to get always the numeric id as the first element of the tuple. Note that this is not happening at the last element of the list I show in the example.
How can I do to get this? I need to iterate over the edges later and I need to take into account the order on the edges, meaning that I need the first element of the tuple to be the numeric id always.
The question is how can I achieve this while reading the graph or after doing it?