当前位置: 首页>>代码示例>>Python>>正文


Python Graph.is_directed方法代码示例

本文整理汇总了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")
开发者ID:jeffalstott,项目名称:richclub,代码行数:15,代码来源:richclub.py

示例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())
开发者ID:hetieke,项目名称:precis,代码行数:7,代码来源:test_igraph.py

示例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)
开发者ID:afrancis13,项目名称:MAS-Solver,代码行数:32,代码来源:fosters.py


注:本文中的igraph.Graph.is_directed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。