Created
July 18, 2013 06:01
-
-
Save yuugit/6027007 to your computer and use it in GitHub Desktop.
an util for networkx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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