我有2种节点类型,其中TypeA始终指向TypeB,TypeB没有出站边。
如何使用igraph?
将其指示为有向图?答案 0 :(得分:9)
http://igraph.org/python/doc/igraph.Graph-class.html#init
g = Graph(directed=True)
g.add_vertices(2)
g.add_edges([(0,1)])
g.degree(mode="in") # -> [0, 1]
g.degree(mode="out") # -> [1, 0]