I'm very new to networkX. So having problem in very basic things.
I've network data in the text file in following format:
InNode OutNode
N1 N5
N2 N4
N3 N6
N2 N2
N4 N7
My questions are the following:
1) How to read the data using networkX, so that I can get the nodes and edges between the graph?
2) How to calculate the self-edge of the network (N2, N2)?
I tried the following code. But it's not giving me the right answer.
import matplotlib
import networkx as net
import urllib
import csv
g = net.Graph()
f1 = csv.reader(open("data.txt","rb"))
for row in f1:
g.add_nodes_from(row)
len(g)
g.number_of_nodes()