Skip to content

Instantly share code, notes, and snippets.

@yuugit
Created July 18, 2013 06:01
Show Gist options
  • Save yuugit/6027007 to your computer and use it in GitHub Desktop.
Save yuugit/6027007 to your computer and use it in GitHub Desktop.
an util for networkx
def adj_iter(network, x):
u"""network のノード x に隣接するエッジのイテレータを返す。
素の edges_iter は存在しないノードに対してエラーを吐き面倒なので
このジェネレータ関数で回避する。
"""
if network.has_node(x):
for t in network.edges_iter(x):
yield t
else:
raise StopIteration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment