Jerry
unread,Oct 15, 2010, 2:00:10 PM10/15/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to networkx-discuss
Hi, I was working with the ego_graph function today and got some odd
behavior so I wanted to make sure that I understood what I was seeing.
I have an undirected, weighted graph (H) and wanted to find edges
within a certain distance (e.g. 50 units) of a particular node. I
found the ego_graph function and fed in the following parameters:
>>> q = nx.ego_graph(H, 'n509', radius = 50, undirected=True)
I was assuming that the radius was based on the edge weights. When I
looked at the results I found that I had a subgraph with 4870 nodes
and 5385 edges The answer I expected was 1 node and 1 edge.
>>> len(q)
4870
>>> len(q.edges())
5385
Then I tried the following:
>>> q = nx.ego_graph(H, 'n509', radius = 1, undirected=True)
>>> for i in q.edges(data=True):
print i
(u'n502', 'n509', {u'building': u'sidewalks', u'weight': 33,
u'lineslope': 0, u'floor': None, u'modcounti': 0, u'modified': False})
('n509', u'n557', {u'building': u'sidewalks', u'weight': 192,
u'lineslope': 5, u'floor': None, u'modcounti': 0, u'modified': False})
('n509', u'n274', {u'building': u'sidewalks', u'weight': 81,
u'lineslope': 9, u'floor': None, u'modcounti': 0, u'modified': False})
>>> nx.degree(H, 'n509')
3
So, it looks like it is working on n-order neighbors. Is this
correct? I thought it was based on edge-weights rather than neighbor
order - but when I run the following I get identical results for the
1st order neighbors:
>>> r = nx.neighbors(H, 'n509')
>>> r
[u'n502', u'n557', u'n274']
The graph is generated from a mongoDB collection which bring in the
unicode part - is it just not recognizing the weight parameter? Or
did I misunderstand the function? Or both...?
Thanks for any information.
Jerry