How to use pydot - 10 common examples

To help you get started, we’ve selected a few pydot 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 midonet / midonet / tests / tools / topoloviz / build / pydot / setup.py View on Github external
except ImportError, excp:
    from setuptools import setup
    
import pydot
import os

os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
os.environ['COPYFILE_DISABLE'] = 'true'

setup(	name = 'pydot',
    version = pydot.__version__,
    description = 'Python interface to Graphviz\'s Dot',
    author = 'Ero Carrera',
    author_email = 'ero@dkbza.org',
    url = 'http://code.google.com/p/pydot/',
    download_url = 'http://pydot.googlecode.com/files/pydot-%s.tar.gz' % pydot.__version__,
    license = 'MIT',
    keywords = 'graphviz dot graphs visualization',
    platforms = ['any'],
    classifiers =	['Development Status :: 5 - Production/Stable',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Topic :: Scientific/Engineering :: Visualization',
        'Topic :: Software Development :: Libraries :: Python Modules'],
    long_description = "\n".join(pydot.__doc__.split('\n')),
    py_modules = ['pydot', 'dot_parser'],
    install_requires = ['pyparsing', 'setuptools'],
    data_files = [('.', ['LICENSE', 'README'])] )
github midonet / midonet / tests / tools / topoloviz / topoloviz.py View on Github external
for bridge in bridges:
            bridge_node = Node(get_device_id(bridge),
                                label=get_device_label(bridge, 'Bridge'),
                                shape='box')
            tenant_cluster.add_node(bridge_node)

            for p in dao.get_ports_by_bridge_id(bridge['id']):
                seen_port_ids.add(p['id'])


                bridge_port_node = Node(shorten_uuid(p['id']),
                                        label=get_port_label(p))
                tenant_cluster.add_node(bridge_port_node)
                tenant_cluster.add_edge(
                    Edge(bridge_node, shorten_uuid(p['id'])))

                if p['type'] == 'InteriorBridge':
                    if p['peerId']:
                        if p['peerId'] in seen_port_ids:
                            continue

                        peer_port = dao.get_port_by_id(p['peerId'])
                        peer_device_id = peer_port['deviceId']

                        edge =  Edge(bridge_port_node,
                                     shorten_uuid(peer_port['id']))

                        if peer_port['type'].endswith('Bridge'):
                            other_tenant_id = dao.get_bridge_by_id(
                                peer_device_id)['tenantId']
github dvklopfenstein / PrincetonAlgorithms / py / AlgsSedgewickWayne / testcode / binary_heaps.py View on Github external
def wr_png_array(bh_st, kwargs):
  """Given an array for a binary heap, draw tree."""
  import pydot
  prt = sys.stdout if 'prt' not in kwargs else kwargs['prt']
  fout_png = "binary_heap_{}.png".format('_'.join(str(e) for e in bh_st))
  label = get_png_label(bh_st, kwargs)
  # 1. Create/initialize Graph
  G = pydot.Dot(label=label, graph_type='digraph') # Directed Graph
  edge_idxs = get_edges(bh_st)
  badcol = {c:'#fe2f4a' for p, c in edge_idxs if bh_st[p] < bh_st[c]}
  # 2. Create Nodes
  mknode = lambda i, v: pydot.Node(
    "{V}[{I}]".format(I=i+1, V=v), 
    style = "filled",
    fillcolor = badcol.get(i, "beige"))
  nodes = [mknode(i,v) for i, v in enumerate(bh_st) if v is not None]
  # 3. Add nodes to Graph
  for node in nodes:
    G.add_node(node)
  # 4. Add Edges between Nodes to Graph
  for p, c in edge_idxs:
    G.add_edge(pydot.Edge(nodes[p], nodes[c]))
  # 5. Write Graph to png file
  G.write_png(fout_png)
github columbia / fairtest / src_new_api / fairtest / bugreport / trees / categorical_tree.py View on Github external
----------
    tree :
        The tree structure

    outfile :
        The output file

    encoders :
        The encoders used to encode categorical features

    is_spark :
        If the tree was produced by Spark or not
    """
    dot_data = StringIO()
    export_graphviz(tree, encoders, out_file=dot_data, is_spark=is_spark)
    graph = pydot.graph_from_dot_data(dot_data.getvalue())
    graph.write_pdf(outfile)
github midonet / midonet / tests / tools / topoloviz / topoloviz.py View on Github external
if args.prompt_password:
            password = raw_input('Password for MidoNet API: ')
        dao = vta.MidoNetApi(args.midonet_url, args.username, password,
                             args.tenant_id)

    for tenant in dao.get_tenants():

        tenant_cluster = Cluster(get_tenant_cluster_id(tenant['id']),
                                 label=get_tenant_label(tenant['id']))

        for chain in dao.get_chains_by_tenant_id(tenant['id']):
            chain_node = Node(chain['id'],
                              label=get_device_label(chain, 'Chain'))


            chain_cluster = Cluster(chain['id'].replace('-', '_'),
                                    label=get_device_label(chain, 'Chain'))
            tenant_cluster.add_subgraph(chain_cluster)

            rules = dao.get_rules_by_chain_id(chain['id'])
            for rule in rules:
                rule_node = Node(rule['id'],
                                 label=get_rule_label(rule),
                                 shape='box')
                chain_cluster.add_node(rule_node)

        routers = dao.get_routers_by_tenant_id(tenant['id'])
        for router in routers:
            router_node = Node(get_device_id(router),
                                     label=get_device_label(router, 'Router'),
                                     shape='box')
            tenant_cluster.add_node(router_node)
github pydot / pydot / test / test_pydot.py View on Github external
def digraph():
    return pydot.Graph("testgraph", graph_type="digraph")
github midonet / midonet / tests / tools / topoloviz / build / pydot / dot_parser.py View on Github external
def push_edge_stmt(str, loc, toks):
    
    tok_attrs = [a for a in toks if isinstance(a, P_AttrList)]
    attrs = {}
    for a in tok_attrs:
        attrs.update(a.attrs)

    e = []

    if isinstance(toks[0][0], pydot.Graph):
    
        n_prev = pydot.frozendict(toks[0][0].obj_dict)
    else:        
        n_prev = toks[0][0] + do_node_ports( toks[0] )

    if isinstance(toks[2][0], ParseResults):
    
        n_next_list = [[n.get_name(),] for n in toks[2][0] ]
        for n_next in [n for n in n_next_list]:
            n_next_port = do_node_ports(n_next)
            e.append(pydot.Edge(n_prev, n_next[0]+n_next_port, **attrs))

    elif isinstance(toks[2][0], pydot.Graph):
    
        e.append(pydot.Edge(n_prev, pydot.frozendict(toks[2][0].obj_dict), **attrs))

    elif isinstance(toks[2][0], pydot.Node):
github midonet / midonet / tests / tools / topoloviz / build / pydot / dot_parser.py View on Github external
if not item_dict.has_key( key_name ):
            continue

        for key, objs in item_dict[key_name].items():
            for obj in objs:
                if 'parent_graph' in obj and obj['parent_graph'].get_parent_graph()==g:
                    if obj['parent_graph'] is g:
                        pass
                    else:
                        obj['parent_graph'].set_parent_graph(parent_graph)

                if key_name == 'edges' and len(key) == 2:
                    for idx, vertex in enumerate( obj['points'] ):
                        if isinstance( vertex, (pydot.Graph, pydot.Subgraph, pydot.Cluster)):
                            vertex.set_parent_graph(parent_graph)
                        if isinstance( vertex, pydot.frozendict):
                            if vertex['parent_graph'] is g:
                                pass
                            else:
                                vertex['parent_graph'].set_parent_graph(parent_graph)
github midonet / midonet / tests / tools / topoloviz / build / pydot / setup.py View on Github external
#!/usr/bin/env python

try:
    from distutils.core import setup
except ImportError, excp:
    from setuptools import setup
    
import pydot
import os

os.environ['COPY_EXTENDED_ATTRIBUTES_DISABLE'] = 'true'
os.environ['COPYFILE_DISABLE'] = 'true'

setup(	name = 'pydot',
    version = pydot.__version__,
    description = 'Python interface to Graphviz\'s Dot',
    author = 'Ero Carrera',
    author_email = 'ero@dkbza.org',
    url = 'http://code.google.com/p/pydot/',
    download_url = 'http://pydot.googlecode.com/files/pydot-%s.tar.gz' % pydot.__version__,
    license = 'MIT',
    keywords = 'graphviz dot graphs visualization',
    platforms = ['any'],
    classifiers =	['Development Status :: 5 - Production/Stable',
        'Intended Audience :: Science/Research',
        'License :: OSI Approved :: MIT License',
        'Natural Language :: English',
        'Operating System :: OS Independent',
        'Programming Language :: Python',
        'Topic :: Scientific/Engineering :: Visualization',
        'Topic :: Software Development :: Libraries :: Python Modules'],
github antoinecarme / pyaf / tests / bugs / issue_36 / display_version_info.py View on Github external
lVersionDict["sklearn_version"] = sklearn.__version__;
    
    import pandas as pd
    lVersionDict["pandas_version"] = pd.__version__;
    
    import numpy as np
    lVersionDict["numpy_version"] = np.__version__;
    
    import scipy as sc
    lVersionDict["scipy_version"] = sc.__version__;
    
    import matplotlib
    lVersionDict["matplotlib_version"] = matplotlib.__version__

    import pydot
    lVersionDict["pydot_version"] = pydot.__version__

    import sqlalchemy
    lVersionDict["sqlalchemy_version"] = sqlalchemy.__version__
    
    print([(k, lVersionDict[k]) for k in sorted(lVersionDict)]);
    return lVersionDict;