Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_label_html():
"""http://www.graphviz.org/doc/info/shapes.html#html"""
dot = Digraph('structs', node_attr={'shape': 'plaintext'})
dot.node('struct1', '''<
<table cellspacing="0" border="0">
<tbody><tr>
<td>left</td>
<td>middle</td>
<td>right</td>
</tr>
</tbody></table>>''')
dot.node('struct2', '''<
<table cellspacing="0" border="0">
<tbody><tr>
<td>one</td>
<td>two</td>
</tr>
</tbody></table>>''')
dot.node('struct3', '''<
@pytest.fixture(params=list(itertools.permutations([Graph, Digraph], 2)),
ids=lambda c: '%s, %s' % (c[0].__name__, c[1].__name__))
def classes(request):
return request.param
def render(self):
"""Call graphviz to create the schema """
self.dot = Digraph(name=self.name, format=self.format,
node_attr={'shape': 'record',
'style': 'filled',
'fillcolor': 'gray95'})
for _, cls in self._nodes.items():
cls.render(self.dot)
for _, edge in self._edges.items():
self.dot.edge(edge['from'], edge['to'],
_attributes=edge['attr'])
def generateGraphvizCode(nodeset, filename="dependencies", rootNode=None, excludeNodeIds=[]):
if rootNode is None or not isinstance(rootNode, Node) or not rootNode in nodeset.nodes:
root = nodeset.getRoot()
else:
root = rootNode
if root is None:
return
g = gv.dot.Digraph(name="NodeSet Dependency", format='pdf', )
alreadyAdded = set()
ignoreNodes = set()
# Ignore some nodes since almost all nodes will point to that which messes up the graph
ignoreNodes.add(NodeId("i=68")) # PropertyType
ignoreNodes.add(NodeId("i=63")) # BaseDataVariableType
ignoreNodes.add(NodeId("i=61")) # FolderType
addNodeToGraph(nodeset, root, g, alreadyAdded, isRoot=True,
relevantReferences=nodeset.getRelevantOrderingReferences(),
ignoreNodes=ignoreNodes)
g.render(filename)
def graphviz(self):
try:
return self._graphviz
except AttributeError:
g = Digraph()
g.attr(rankdir="LR")
g.node("BEGIN", shape="point")
for i in self.outputs_of(BEGIN):
g.edge("BEGIN", str(i))
for ix in self.topologically_sorted_indexes:
g.node(str(ix), label=get_name(self[ix]))
for iy in self.outputs_of(ix):
g.edge(str(ix), str(iy))
self._graphviz = g
return self._graphviz