Issue 122 in python-graph: Get and count node neighbors

9 views
Skip to first unread message

python...@googlecode.com

unread,
Jul 17, 2014, 11:24:42 AM7/17/14
to python...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 122 by phani....@gmail.com: Get and count node neighbors
http://code.google.com/p/python-graph/issues/detail?id=122

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.

infile.txt

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.Graph()
G = nx.read_edgelist('infile.txt', data=[("weight", float)])

def get_triangle(G):
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):
print n1
print n2
print n3

No Erorrs No output


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply all
Reply to author
Forward
0 new messages