本文整理汇总了Python中igraph.Graph.is_directed方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.is_directed方法的具体用法?Python Graph.is_directed怎么用?Python Graph.is_directed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类igraph.Graph
的用法示例。
在下文中一共展示了Graph.is_directed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: graph_from_sparse
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import is_directed [as 别名]
def graph_from_sparse(data, directed=None):
from igraph import Graph
sources, targets = data.nonzero()
if directed==None:
from numpy import all
directed = not all(data[sources, targets]==data[targets, sources])
from numpy import array
g = Graph(zip(sources, targets), directed=directed, edge_attrs={'weight': array(data[sources, targets])[0]})
if g.is_directed():
return g
else:
return g.simplify(combine_edges="first")
示例2: test_should
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import is_directed [as 别名]
def test_should(self):
graph = Graph()
graph.add_vertices(["1", "2"])
graph.add_edge("1", "2",weight=9)
self.assertFalse(graph.is_directed())
示例3: Graph
# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import is_directed [as 别名]
from igraph import Graph
foster = Graph().LCF(90, [17, -9, 37, -37, 9, -17], 15)
foster.to_directed()
print "Is Directed? " + str(foster.is_directed())
for start in range(0, 90):
for end in range(0, 90):
# Don't delete this. Delete opposite direction edge
if start + 1 == end:
opposite_ID = foster.get_eid(end, start, True, False)
if opposite_ID != 1:
foster.delete_edges([opposite_ID])
else:
opposite_ID = foster.get_eid(end, start, True, False)
if opposite_ID != -1:
current_ID = foster.get_eid(start, end, True, False)
if current_ID != -1:
foster.delete_edges([current_ID])
print "Number of Edges: " + str(len(foster.get_edgelist()))
print (foster.is_connected())
foster_list = foster.get_adjacency()
for sublist in foster_list:
sublist = map(str, sublist)
sublist_string = " ".join(sublist)
print (sublist_string)