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


Python Graph.get_adjacency方法代码示例

本文整理汇总了Python中igraph.Graph.get_adjacency方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.get_adjacency方法的具体用法?Python Graph.get_adjacency怎么用?Python Graph.get_adjacency使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在igraph.Graph的用法示例。


在下文中一共展示了Graph.get_adjacency方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: obtain_library_solution

# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import get_adjacency [as 别名]
    def obtain_library_solution(self, scc_adj_matrix, force_ip=False, force_eades=False):
        num_vertices = len(scc_adj_matrix)
        library_graph = Graph().Adjacency(scc_adj_matrix)

        if not force_eades and (num_vertices < 10 or force_ip):
            removed_edges = library_graph.feedback_arc_set(method='ip')
        else:
            removed_edges = library_graph.feedback_arc_set(method='eades')

        library_graph.delete_edges(removed_edges)
        library_graph_adj_matrix = library_graph.get_adjacency()._get_data()
        library_graph_dag_solver = DAGSolver(library_graph_adj_matrix)
        solution = library_graph_dag_solver.topological_sort()

        return solution
开发者ID:afrancis13,项目名称:MAS-Solver,代码行数:17,代码来源:final_solver.py

示例2: Graph

# 需要导入模块: from igraph import Graph [as 别名]
# 或者: from igraph.Graph import get_adjacency [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.get_adjacency方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。