本文整理汇总了Python中networkx.Graph.out_edges方法的典型用法代码示例。如果您正苦于以下问题:Python Graph.out_edges方法的具体用法?Python Graph.out_edges怎么用?Python Graph.out_edges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类networkx.Graph
的用法示例。
在下文中一共展示了Graph.out_edges方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: LangGraph
# 需要导入模块: from networkx import Graph [as 别名]
# 或者: from networkx.Graph import out_edges [as 别名]
#.........这里部分代码省略.........
#add in the reverse types
for edgeType in self.edgeTypes(e,s):
results.add(edgeType)
return results
def allEdges(self):
"""
Yield all the edges in the graph
"""
for start, end in self.graph.edges():
yield start, end, self.edgeTypes(start, end)
def contains(self, instance):
"""
Returns true if the graph contains the instance
"""
return self.graph.has_node(instance)
def instances(self):
"""
Return all the instances in the graph
"""
return self.graph.nodes()
def edges(self, instance):
"""
Returns all the edges connected to this instance
"""
inst = self.indexToInst(instance)
#make get the directed edges
if self.isDirected:
results = [t for _, t in self.graph.out_edges(inst)] + [t for t, _ in self.graph.in_edges(inst)]
else:
results = self.graph.adj[inst]
return results
def docType(self):
"""
Returns the document type (String)
"""
return self.temporal[0].event.docType
def adj(self, instance, type=None):
"""
Returns the adjancent node with a given type
"""
return [other for other in self.edges(instance)
if self.hasType(instance, other, type) or type is None]
def nonNarrativeAdj(self, instance, returnIndex=False):
"""
Returns the nodes that are not adjancent to the given instance
"""
results = []
#add each node if it has a non-narrative (temporal) connection
for node in self.edges(instance):
#get the non narrative types
edgeTypes = nonNarrativeTypes(self.edgeTypes(instance, node))
#if there is a non-narrative edge, add it
if edgeTypes: