本文整理汇总了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
示例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)