python - Initial node's ids when creating graph from edge list -


i wonder, function read_edgelist store original id's the edge list? or under attribute name?

assume reading edge list like:

1 2 2 1  1 3 

where numbers 1,2,3 ids (or names) of nodes. igraph (python version) stores these ids? tried retrieving these ids attribute name or id did not work, 2 attributes, seemingly, must explicitly defined.

read_edgelist assumes node ids consecutive integers 0 m, m maximum integer in edge list. there "no need store node ids."

for example, if edgelist.txt 1 3, code

import igraph ig g = ig.graph.read_edgelist("edgelist.txt") print g.get_adjacency() 

creates graph 4 nodes (0, 1, 2, 3) , prints

[[0, 0, 0, 0]  [0, 0, 0, 1]  [0, 0, 0, 0]  [0, 0, 0, 0]] 

see answer if not want "intermediate" nodes created.

while following unnecessary graph consecutive node ids starting 0, 1 access node ids using vertexseq , vertex:

for v in g.vs:   print v.index   # node id 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -