How to use the graphviz.Digraph function in graphviz

To help you get started, we’ve selected a few graphviz examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github showkeyjar / AutoMakeHuman / test / NEAT / examples / circuits / visualize.py View on Github external
node_names = {}

    assert type(node_names) is dict

    if node_colors is None:
        node_colors = {}

    assert type(node_colors) is dict

    node_attrs = {
        'shape': 'circle',
        'fontsize': '9',
        'height': '0.2',
        'width': '0.2'}

    dot = graphviz.Digraph(format=fmt, node_attr=node_attrs)

    inputs = set()
    for k in config.genome_config.input_keys:
        inputs.add(k)
        name = node_names.get(k, str(k))
        input_attrs = {'style': 'filled',
                       'shape': 'box'}
        input_attrs['fillcolor'] = node_colors.get(k, 'lightgray')
        dot.node(name, _attributes=input_attrs)

    outputs = set()
    for k in config.genome_config.output_keys:
        outputs.add(k)
        name = node_names.get(k, str(k))
        node_attrs = {'style': 'filled'}
        node_attrs['fillcolor'] = node_colors.get(k, 'lightblue')
github hachmannlab / chemml / cheml / notebooks / main.py View on Github external
except Exception as err:
                print "Invalid configuration file ..."
                print "    IOError: %s"%err.message
                print "... Not loaded!"
                selectTe4.icon = 'remove'
                rm = [i for i in self.pages if i not in old]
                for ib in rm:
                    if ib in self.pages:
                        del self.pages[ib]

            self.debut = False
            self.add_page()

            ## clear ouput and update the graph viz
            self.graph.close()
            dot = Digraph(format='png')
            for edge in self.comp_graph:
                dot.node('%i' % edge[0], label='%i %s' % (edge[0], self.pages[edge[0]].title))
                dot.node('%i' % edge[2], label='%i %s' % (edge[2], self.pages[edge[2]].title))
                dot.edge('%i' % edge[0], '%i' % edge[2], label='%s > %s' % (edge[1], edge[3]), labelfontcolor='green')
            self.graph = widgets.Image(value=dot.pipe(), format='png')
            display(self.graph)
github ogrisel / pygbm / pygbm / plotting.py View on Github external
if isinstance(est_or_grower, BaseGradientBoostingMachine):
            add_predictor_node(0)
        elif isinstance(est_or_grower, pygbm.grower.TreeGrower):
            add_grower_node(est_or_grower.root)

    # make lightgbm tree
    if est_lightgbm is not None:
        import lightgbm as lb
        graph = lb.create_tree_digraph(
            est_lightgbm,
            tree_index=tree_index,
            show_info=['split_gain', 'internal_value', 'internal_count',
                       'leaf_count'],
            **kwargs)
    else:
        graph = Digraph(**kwargs)

    # make pygbm tree
    make_pygbm_tree()

    graph.render(view=view)
github EricssonResearch / scott-eu / simulation-ros / src / turtlebot2i / turtlebot2i_scene_graph / src / ros_scene_graph_generator.py View on Github external
#for robot_num in range(1):
    for robot_num in range(len(robot_list)):
        obj_list = extractor.get_objects_from_vision_sensor(robot_list[robot_num].vision_sensor) #NOT ROBUST HERE

        if (obj_list != None):
            # Remove the robot itself from the list
            obj_list = [i for i in obj_list if i.name!=robot_list[robot_num].name]

        # Print detected objects of the vision sensor
        # TODO: print just in debug mode
        #print(robot_list[robot_num].name, robot_list[robot_num].vision_sensor.name, obj_list)

        #############################################
        # generate scene graph
        #############################################
        dot = Digraph(comment='warehouse', format='svg')
        dot.node_attr['shape']='record'
        robot_velocity = get_velocity(robot_list[robot_num])
        i = robot_list[robot_num]
        # print(i.bbox_min[0], i.bbox_min[1], i.bbox_max[0], i.bbox_max[1])
        # robot_label = '{%s|%s|velocity: %.2f|orientation: %.2f}'%(robot[robot_num].name, robot[robot_num].vision_sensor.name, robot_velocity, robot[robot_num].ori[2]*180/pi)
        robot_label = '{%s|%s|velocity: %.2f}'%(robot_list[robot_num].name, robot_list[robot_num].vision_sensor.name, robot_velocity)
        #robot_label = '{%s|type: 0|%s|velocity: %.2f}'%(robot_list[robot_num].name, robot_list[robot_num].vision_sensor.name, robot_velocity) #Label for itself?
         
        # robot_label = '{%s|%s}'%(robot[robot_num].name, robot[robot_num].vision_sensor.name)
        
        dot.node('robot', label=robot_label)
        dot.node('warehouse', label='warehouse')
        dot.node('floor', label='{floor|size: 25*25}')
        dot.edge('warehouse','floor')

        for obj in obj_list:
github IBM / yaps / yaps / ir.py View on Github external
def __init__(self, blocks):
        self.blocks = blocks
        self.dot = graphviz.Digraph()
        self.dot.attr('graph', rankdir='LR')
github leanprover / lean4 / extras / depgraph / leandeps.py View on Github external
def lean_deps(lean_files, prefixes, oname):
    visited = dict()
    graph   = graphviz.Digraph(name=oname,format='dot')
    lean_deps_core(lean_files, prefixes, visited, graph)
    graph.render()
github sassoftware / python-esppy / esppy / project.py View on Github external
Should window schemas be included?
        template_detail : bool, optional
            Should template detail be shown?

        Returns
        -------
        :class:`graphviz.Digraph`

        '''
        try:
            import graphviz as gv
        except ImportError:
            raise ImportError('The graphviz module is required for exporting to graphs.')

        if graph is None:
            graph = gv.Digraph(format='svg')
            graph.attr('node', shape='rect', fontname='helvetica')
            graph.attr('graph', rankdir='LR', center='false')
            graph.attr('edge', fontname='times-italic')

        if self.queries:
            pgraph = gv.Digraph(format='svg',
                                name='cluster_%s' % self.fullname.replace('.', '_'))
            pgraph.attr('graph', fontname='helvetica')
            pgraph.attr('edge', fontname='times-italic')
            pgraph.attr(label=self.name, labeljust='l',
                        style='filled,bold,rounded', color='#c0c0c0',
                        fillcolor='#dadada', fontcolor='black')

            if list(self.queries.keys()) == [self.default_query]:
                if self.templates:
                    for tkey, template in sorted(self.templates.items()):
github gil9red / SimplePyScripts / graph__networkx__d3__dot_graphviz / graphviz__examples / generate__as__format_svg.py View on Github external
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = 'ipetrash'


# pip install graphviz
from graphviz import Digraph

g = Digraph('G', filename='test-output/hello_world.gv', format='svg')
g.edge('Hello', 'World')

out_file_name = g.render()
print(out_file_name)
github rustychris / stompy / stompy / model / delft / process_diagram.py View on Github external
def init_dot(self):
        # strict merges duplicate edges

        # dot is the only one which gives reasonable output
        # could also add in size="5,5"
        from graphviz import Digraph

        dot = Digraph(name="schematic-%s"%self.run_name,
                      comment='WAQ Processes',strict=True,engine='dot')
        #dot.attr('graph',ranksep="0.4",ratio='auto')
        dot.attr('graph',ranksep="0.3",ratio='0.647')
        dot.attr('node',fontname='Helvetica',style='filled',fillcolor='gray80',fontsize="32")
        dot.attr('edge',penwidth="2")

        return dot
github smearle / gym-city / visualize.py View on Github external
def network_graphs():
    dot = Digraph(comment='StrictlyConv', node_attr={'shape': 'box'})
    dot.edge_attr.update(arrowhead='vee')
    dot.edge_attr.update(color=color_defaults[0])
    dot.node_attr.update(width='2', height='0.2')
    dot.node('A', 'Map', shape='box')
    dot.node('B', '')
    dot.node('C', '')
    dot.node('D', 'Action Map')
    dot.edge('A', 'B', label='c_{k5}')
    dot.edge('B', 'C', label='c_{k3}')
    dot.edge('C', 'D')
    dot.node('E', '', width='1')
    dot.edge('C', 'E', label='d')
    dot.node('F', '', width='0.5')
    dot.edge('E', 'F', label='d')
    dot.node('G', '', width='0.25')
    dot.edge('F', 'G', label='d')