New to Python and Python mail List
phani.lav at gmail.com
Thu Jul 17 17:39:40 CEST 2014
I am very much new to python scripting and i am here for knowledge
I am trying to read a file with node pairs and weight.
I have to find the neighbours of each pair individual and combined
both also count them.
Later find the ratio of the neighbours that each node has. I am stuck
with finding nodes.
0_node1 0_node2 0w
1_node1 1_node2 1w
2_node1 2_node2 2w
3_node1 3_node2 3w
4_node1 4_node2 4w
import networkx as nx
import matplotlib.pyplot as plt
G = nx.read_edgelist('infile.txt', data=[("weight", float)])
for n1 in G.nodes:
neighbors1 = set(G[n1])
for n2 in filter(lambda x: x>n1, nodes):
neighbors2 = set(G[n2])
common = neighbors1 & neighbors2
for n3 in filter(lambda x: x>n2, common):
Any suggestion will be appreciated. Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list