Print Node Id from Igraph in Python
<p>I have text file with the following sample data representing nodes and edges. </p>

<pre><code>a b
b c
d a
b d
</code></pre>

<p>I want to print the node ID in python but I realize that there is no way to achieve this,for example in R once I generate my graph, I get the node attribute name printed along with the pagerank score. In the case of python, I am trying to generate the pagerank score which I achieve with python code:</p>

<pre><code>Fin = Graph.Read_Ncol('test.txt',directed = True)
#print(Fin)
PRankH = Graph.pagerank( Fin, directed =True,damping = 0.85)
print(PRankH)
print(PRankH.index)
for item in PRankH:
    print(PRankH.index(item),PRankH[item])
</code></pre>

<p>The output printed is just the pagerank scores for example the Node id and the scores:</p>

<pre><code>0.0001, 000.2, 0.0003
</code></pre>

<p>How ever I would want to print for example</p>

<pre><code>A 0.0001 , B 0.0002 , C 0.0003
</code></pre>

<p>Is there any way I can achieve this from the python I graph library?</p>

<p>If anyone is interested, I ended solving my own problem. The values generated by the graph in  python are linked by the vertex id. You will need to access the vertex name attribute for your graph and linked that with eh scores produced from the page rank output. </p>

<pre><code>Fin = Graph.Read_Ncol('Node_edge.txt',directed = True)
PRankH = Graph.pagerank( Fin, directed =True,damping = 0.85)
x = 0
for item in PRankH:    
     print([Fin.vs[x]['name'],PRankH[x]]))
     x+=1
myfile.close()
</code></pre>

<p>This is an example of how I solved the the issue. </p>

python igraph