DiGraph.nodes_with_selfloops() Return a list of nodes with self loops. DiGraph.selfloop_edges([data]) Return a list of selfloop edges. DiGraph.number_of_selfloops() Return the number of selfloop edges.

# now run it 10k timeslong_paths2=lng_path_cnt(G,20000)plt.bar(long_paths2.keys(),long_paths2.values(),0.25,color='g',align='center')lp=np.max([kforkinlong_paths2])plt.vlines(lp,0,2000,color='r',linestyles=':')plt.text(lp-1,1000,"long path count: %d"%lp,rotation=90,verticalalignment='center')