当前位置: 首页>>代码示例>>Python>>正文


Python pydot_ng.Dot方法代码示例

本文整理汇总了Python中pydot_ng.Dot方法的典型用法代码示例。如果您正苦于以下问题:Python pydot_ng.Dot方法的具体用法?Python pydot_ng.Dot怎么用?Python pydot_ng.Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pydot_ng的用法示例。


在下文中一共展示了pydot_ng.Dot方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_simple_graph_with_node

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def test_create_simple_graph_with_node():
    graph = pydot.Dot(graph_type="digraph")

    node = pydot.Node("legend")
    node.set("shape", "box")
    node.set("label", "mine")

    graph.add_node(node)

    assert graph.to_string() == dedent(
        """\
        digraph G {
        legend [label=mine, shape=box];
        }
        """
    ) 
开发者ID:pydot,项目名称:pydot-ng,代码行数:18,代码来源:test_pydot.py

示例2: test_unicode_ids

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def test_unicode_ids():
    node1 = '"aánñoöüé€"'
    node2 = '"îôø®çßΩ"'

    graph = pydot.Dot()
    graph.set_charset("latin1")
    graph.add_node(pydot.Node(node1))
    graph.add_node(pydot.Node(node2))
    graph.add_edge(pydot.Edge(node1, node2))

    assert graph.get_node(node1)[0].get_name() == node1
    assert graph.get_node(node2)[0].get_name() == node2

    assert graph.get_edges()[0].get_source() == node1
    assert graph.get_edges()[0].get_destination() == node2

    graph2 = pydot.graph_from_dot_data(graph.to_string())

    assert graph2.get_node(node1)[0].get_name() == node1
    assert graph2.get_node(node2)[0].get_name() == node2

    assert graph2.get_edges()[0].get_source() == node1
    assert graph2.get_edges()[0].get_destination() == node2 
开发者ID:pydot,项目名称:pydot-ng,代码行数:25,代码来源:test_pydot.py

示例3: _create_graph

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def _create_graph(structure_dict):
    """Creates pydot graph from the pipeline structure dict.

    Args:
        structure_dict (dict): dict returned by step.upstream_structure

    Returns:
        graph (pydot.Dot): object representing upstream pipeline structure (with regard to the current Step).
    """
    graph = pydot.Dot()
    for node in structure_dict['nodes']:
        graph.add_node(pydot.Node(node))
    for node1, node2 in structure_dict['edges']:
        graph.add_edge(pydot.Edge(node1, node2))
    return graph 
开发者ID:sattree,项目名称:gap,代码行数:17,代码来源:utils.py

示例4: _check_pydot

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def _check_pydot():
    try:
        # Attempt to create an image of a blank graph
        # to check the pydot/graphviz installation.
        pydot.Dot.create(pydot.Dot())
    except Exception:
        # pydot raises a generic Exception here,
        # so no specific class can be caught.
        raise ImportError('Failed to import pydot. You must install pydot'
                          ' and graphviz for `pydotprint` to work.') 
开发者ID:hello-sea,项目名称:DeepLearning_Wavelet-LSTM,代码行数:12,代码来源:vis_utils.py

示例5: create_graph

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def create_graph(graph_info):
    dot = pydot.Dot()
    for node in graph_info['nodes']:
        dot.add_node(pydot.Node(node))
    for node1, node2 in graph_info['edges']:
        dot.add_edge(pydot.Edge(node1, node2))
    return dot 
开发者ID:minerva-ml,项目名称:open-solution-data-science-bowl-2018,代码行数:9,代码来源:utils.py

示例6: test_keep_graph_type

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def test_keep_graph_type(graph_type):
    graph = pydot.Dot(graph_name="Test", graph_type=graph_type)
    assert graph.get_type() == graph_type
    assert graph.graph_type == graph_type 
开发者ID:pydot,项目名称:pydot-ng,代码行数:6,代码来源:test_pydot.py

示例7: test_executable_not_found_exception

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def test_executable_not_found_exception():
    graph = pydot.Dot("graphname", graph_type="digraph")

    paths = {"dot": "invalid_executable_path"}
    graph.set_graphviz_executables(paths)

    with pytest.raises(pydot.InvocationException):
        graph.create() 
开发者ID:pydot,项目名称:pydot-ng,代码行数:10,代码来源:test_pydot.py

示例8: model_to_dot

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def model_to_dot(model, show_shapes=False, show_layer_names=True):
    dot = pydot.Dot()
    dot.set('rankdir', 'TB')
    dot.set('concentrate', True)
    dot.set_node_defaults(shape='record')

    if model.__class__.__name__ == 'Sequential':
        if not model.built:
            model.build()
        model = model.model
    layers = model.layers

    # first, populate the nodes of the graph
    for layer in layers:
        layer_id = str(id(layer))
        if show_layer_names:
            label = str(layer.name) + ' (' + layer.__class__.__name__ + ')'
        else:
            label = layer.__class__.__name__

        if show_shapes:
            # Build the label that will actually contain a table with the
            # input/output
            try:
                outputlabels = str(layer.output_shape)
            except:
                outputlabels = 'multiple'
            if hasattr(layer, 'input_shape'):
                inputlabels = str(layer.input_shape)
            elif hasattr(layer, 'input_shapes'):
                inputlabels = ', '.join(
                    [str(ishape) for ishape in layer.input_shapes])
            else:
                inputlabels = 'multiple'
            label = '%s\n|{input:|output:}|{{%s}|{%s}}' % (label, inputlabels, outputlabels)

        node = pydot.Node(layer_id, label=label)
        dot.add_node(node)

    # second, add the edges
    for layer in layers:
        layer_id = str(id(layer))
        for i, node in enumerate(layer.inbound_nodes):
            node_key = layer.name + '_ib-' + str(i)
            if node_key in model.container_nodes:
                # add edges
                for inbound_layer in node.inbound_layers:
                    inbound_layer_id = str(id(inbound_layer))
                    layer_id = str(id(layer))
                    dot.add_edge(pydot.Edge(inbound_layer_id, layer_id))
    return dot 
开发者ID:GUR9000,项目名称:KerasNeuralFingerprint,代码行数:53,代码来源:visualize_util.py

示例9: push_top_graph_stmt

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Dot [as 别名]
def push_top_graph_stmt(str, loc, toks):
    attrs = {}
    g = None

    for element in toks:
        if (isinstance(element, (pyparsing.ParseResults, tuple, list)) and
                len(element) == 1 and isinstance(element[0], basestring)):
            element = element[0]

        if element == 'strict':
            attrs['strict'] = True

        elif element in ['graph', 'digraph']:
            attrs = {}

            g = pydot.Dot(graph_type=element, **attrs)
            attrs['type'] = element

            top_graphs.append(g)

        elif isinstance(element, basestring):
            g.set_name(element)

        elif isinstance(element, pydot.Subgraph):
            g.obj_dict['attributes'].update(element.obj_dict['attributes'])
            g.obj_dict['edges'].update(element.obj_dict['edges'])
            g.obj_dict['nodes'].update(element.obj_dict['nodes'])
            g.obj_dict['subgraphs'].update(element.obj_dict['subgraphs'])
            g.set_parent_graph(g)

        elif isinstance(element, P_AttrList):
            attrs.update(element.attrs)

        elif isinstance(element, (pyparsing.ParseResults, list)):
            add_elements(g, element)

        else:
            raise ValueError("Unknown element statement: %r " % element)

    for g in top_graphs:
        update_parent_graph_hierarchy(g)

    if len(top_graphs) == 1:
        return top_graphs[0]

    return top_graphs 
开发者ID:pydot,项目名称:pydot-ng,代码行数:48,代码来源:_dotparser.py


注:本文中的pydot_ng.Dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。