本文整理汇总了Python中pydot.Dot.leftNodesLookup[nodeLabel]方法的典型用法代码示例。如果您正苦于以下问题:Python Dot.leftNodesLookup[nodeLabel]方法的具体用法?Python Dot.leftNodesLookup[nodeLabel]怎么用?Python Dot.leftNodesLookup[nodeLabel]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pydot.Dot
的用法示例。
在下文中一共展示了Dot.leftNodesLookup[nodeLabel]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RenderSIPCollection
# 需要导入模块: from pydot import Dot [as 别名]
# 或者: from pydot.Dot import leftNodesLookup[nodeLabel] [as 别名]
def RenderSIPCollection(sipGraph, dot=None):
try:
from pydot import Node, Edge, Dot
except:
import warnings
warnings.warn("Missing pydot library", ImportWarning)
if not dot:
dot = Dot(graph_type='digraph')
dot.leftNodesLookup = {}
nodes = {}
for N, prop, q in sipGraph.query(
'SELECT ?N ?prop ?q { ?prop a magic:SipArc . ?N ?prop ?q . }',
initNs={u'magic': MAGIC}):
if MAGIC.BoundHeadPredicate in sipGraph.objects(
subject=N, predicate=RDF.type):
NCol = [N]
else:
NCol = Collection(sipGraph, N)
if q not in nodes:
newNode = Node(makeMD5Digest(q),
label=normalizeTerm(q, sipGraph),
shape='plaintext')
nodes[q] = newNode
dot.add_node(newNode)
bNode = BNode()
nodeLabel = ', '.join([normalizeTerm(term, sipGraph)
for term in NCol])
edgeLabel = ', '.join([var.n3()
for var in Collection(sipGraph,
first(sipGraph.objects(
prop, MAGIC.bindings)))])
markedEdgeLabel = ''
if nodeLabel in dot.leftNodesLookup:
bNode, leftNode, markedEdgeLabel = dot.leftNodesLookup[nodeLabel]
# print("\t", nodeLabel, edgeLabel,
# markedEdgeLabel, not edgeLabel == markedEdgeLabel
else:
leftNode = Node(makeMD5Digest(bNode),
label=nodeLabel, shape='plaintext')
dot.leftNodesLookup[nodeLabel] = (bNode, leftNode, edgeLabel)
nodes[bNode] = leftNode
dot.add_node(leftNode)
if not edgeLabel == markedEdgeLabel:
edge = Edge(leftNode,
nodes[q],
label=edgeLabel)
dot.add_edge(edge)
return dot