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


Python pydot_ng.Node方法代码示例

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


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

示例1: test_create_simple_graph_with_node

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [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 Node [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 Node [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: dict_to_pdnode

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def dict_to_pdnode(d):
    """Create pydot node from dict."""
    e = dict()
    for k, v in iteritems(d):
        if v is not None:
            if isinstance(v, list):
                v = '\t'.join([str(x) for x in v])
            else:
                v = str(v)
            v = str(v)
            v = v.replace('"', '\'')
            e[k] = v
    pynode = pd.Node(**e)
    return pynode 
开发者ID:muhanzhang,项目名称:D-VAE,代码行数:16,代码来源:formatting.py

示例5: create_graph

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [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: push_node_stmt

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def push_node_stmt(s, loc, toks):

    if len(toks) == 2:
        attrs = toks[1].attrs
    else:
        attrs = {}

    node_name = toks[0]
    if isinstance(node_name, list) or isinstance(node_name, tuple):
        if len(node_name) > 0:
            node_name = node_name[0]

    n = pydot.Node(str(node_name), **attrs)
    return n 
开发者ID:pydot,项目名称:pydot-ng,代码行数:16,代码来源:_dotparser.py

示例7: test_node_style

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_node_style():
    node = pydot.Node("mynode")
    assert node.get_style() is None

    node.add_style("abc")
    assert node.get_style() == "abc"

    node.add_style("def")
    assert node.get_style() == "abc,def"

    node.add_style("ghi")
    assert node.get_style() == "abc,def,ghi" 
开发者ID:pydot,项目名称:pydot-ng,代码行数:14,代码来源:test_pydot.py

示例8: test_numeric_node_id

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_numeric_node_id(digraph):
    digraph.add_node(pydot.Node(1))
    assert digraph.get_nodes()[0].get_name() == "1" 
开发者ID:pydot,项目名称:pydot-ng,代码行数:5,代码来源:test_pydot.py

示例9: test_quoted_node_id

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_quoted_node_id(digraph):
    digraph.add_node(pydot.Node('"node"'))
    assert digraph.get_nodes()[0].get_name() == '"node"' 
开发者ID:pydot,项目名称:pydot-ng,代码行数:5,代码来源:test_pydot.py

示例10: test_quoted_node_id_to_string_no_attributes

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_quoted_node_id_to_string_no_attributes(digraph):
    digraph.add_node(pydot.Node('"node"'))
    assert digraph.get_nodes()[0].to_string() == '"node";' 
开发者ID:pydot,项目名称:pydot-ng,代码行数:5,代码来源:test_pydot.py

示例11: test_keyword_node_id

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_keyword_node_id(digraph):
    digraph.add_node(pydot.Node("node"))
    assert digraph.get_nodes()[0].get_name() == "node" 
开发者ID:pydot,项目名称:pydot-ng,代码行数:5,代码来源:test_pydot.py

示例12: test_keyword_node_id_to_string_with_attributes

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_keyword_node_id_to_string_with_attributes(digraph):
    digraph.add_node(pydot.Node("node", shape="box"))
    assert digraph.get_nodes()[0].to_string() == "node [shape=box];" 
开发者ID:pydot,项目名称:pydot-ng,代码行数:5,代码来源:test_pydot.py

示例13: test_names_of_a_thousand_nodes

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_names_of_a_thousand_nodes(digraph):
    names = set(["node_%05d" % i for i in xrange(10 ** 4)])

    for name in names:
        digraph.add_node(pydot.Node(name, label=name))

    assert set([n.get_name() for n in digraph.get_nodes()]) == names 
开发者ID:pydot,项目名称:pydot-ng,代码行数:9,代码来源:test_pydot.py

示例14: test_quoting

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [as 别名]
def test_quoting():
    import string

    g = pydot.Dot()
    g.add_node(pydot.Node("test", label=string.printable))
    data = g.create(format="jpe")
    assert len(data) > 0 
开发者ID:pydot,项目名称:pydot-ng,代码行数:9,代码来源:test_pydot.py

示例15: model_to_dot

# 需要导入模块: import pydot_ng [as 别名]
# 或者: from pydot_ng import Node [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


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