Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python-igraph number of vertices

I am using python-igraph package to create a graph from my edges stored in a file. I use Graph.Read_Edgelist to read the edges and create my desired graph. When I need to get the number of vertices in my graph I use the Graph.vcount() function which is supposed to return number of vertices which is not the case for me. For a file like this:

1 2
5 300

This function returns 301 which is not what I am looking for ! I need it to return 4 which is the actual number of vertices of my graph. Any idea what I can do to solve this problem?

like image 935
ahajib Avatar asked Dec 11 '25 01:12

ahajib


1 Answers

Solved my problem using the following function instead of Graph.Read_Edgelist:

Graph.Read_Ncol(netFile, names=True, weights="if_present", directed=True)

By setting "name=True" the function considers the nodes numbers as their name and solves the vcount problem.

like image 106
ahajib Avatar answered Dec 12 '25 14:12

ahajib



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!