當前位置: 首頁>>代碼示例>>Python>>正文


Python pydotplus.Dot方法代碼示例

本文整理匯總了Python中pydotplus.Dot方法的典型用法代碼示例。如果您正苦於以下問題:Python pydotplus.Dot方法的具體用法?Python pydotplus.Dot怎麽用?Python pydotplus.Dot使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pydotplus的用法示例。


在下文中一共展示了pydotplus.Dot方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_unicode_ids

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def test_unicode_ids(self):

        node1 = '"aánñoöüé€"'
        node2 = '"îôø®çßΩ"'

        g = pydotplus.Dot()
        g.set_charset('latin1')
        g.add_node(pydotplus.Node(node1))
        g.add_node(pydotplus.Node(node2))
        g.add_edge(pydotplus.Edge(node1, node2))

        self.assertEqual(g.get_node(node1)[0].get_name(), node1)
        self.assertEqual(g.get_node(node2)[0].get_name(), node2)

        self.assertEqual(g.get_edges()[0].get_source(), node1)
        self.assertEqual(g.get_edges()[0].get_destination(), node2)

        g2 = pydotplus.graph_from_dot_data(g.to_string())

        self.assertEqual(g2.get_node(node1)[0].get_name(), node1)
        self.assertEqual(g2.get_node(node2)[0].get_name(), node2)

        self.assertEqual(g2.get_edges()[0].get_source(), node1)
        self.assertEqual(g2.get_edges()[0].get_destination(), node2) 
開發者ID:carlos-jenkins,項目名稱:pydotplus,代碼行數:26,代碼來源:pydot_unittest.py

示例2: bpmn_diagram_to_png

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def bpmn_diagram_to_png(bpmn_diagram, file_name):
    """
    Create a png picture for given diagram

    :param bpmn_diagram: an instance of BPMNDiagramGraph class,
    :param file_name: name of generated file.
    """
    g = bpmn_diagram.diagram_graph
    graph = pydotplus.Dot()

    for node in g.nodes(data=True):

        if node[1].get(consts.Consts.type) == consts.Consts.task:
            n = pydotplus.Node(name=node[0], shape="box", style="rounded", label=node[1].get(consts.Consts.node_name))
        elif node[1].get(consts.Consts.type) == consts.Consts.exclusive_gateway:
            n = pydotplus.Node(name=node[0], shape="diamond", label=node[1].get(consts.Consts.node_name))
        else:
            n = pydotplus.Node(name=node[0], label=node[1].get(consts.Consts.node_name))
        graph.add_node(n)

    for edge in g.edges(data=True):
        e = pydotplus.Edge(src=edge[0], dst=edge[1], label=edge[2].get(consts.Consts.name))
        graph.add_edge(e)

    graph.write(file_name + ".png", format='png') 
開發者ID:KrzyHonk,項目名稱:bpmn-python,代碼行數:27,代碼來源:bpmn_diagram_visualizer.py

示例3: _check_pydot

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus 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

示例4: test_keep_graph_type

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def test_keep_graph_type(self):

        g = pydotplus.Dot(graph_name='Test', graph_type='graph')

        self.assertEqual(g.get_type(), 'graph')

        g = pydotplus.Dot(graph_name='Test', graph_type='digraph')

        self.assertEqual(g.get_type(), 'digraph') 
開發者ID:carlos-jenkins,項目名稱:pydotplus,代碼行數:11,代碼來源:pydot_unittest.py

示例5: test_create_simple_graph_with_node

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def test_create_simple_graph_with_node(self):

        g = pydotplus.Dot()
        g.set_type('digraph')
        node = pydotplus.Node('legend')
        node.set("shape", 'box')
        g.add_node(node)
        node.set('label', 'mine')

        self.assertEqual(
            g.to_string(),
            'digraph G {\nlegend [label=mine, shape=box];\n}\n'
        ) 
開發者ID:carlos-jenkins,項目名稱:pydotplus,代碼行數:15,代碼來源:pydot_unittest.py

示例6: test_executable_not_found_exception

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def test_executable_not_found_exception(self):
        paths = {'dot': 'invalid_executable_path'}

        graph = pydotplus.Dot('graphname', graph_type='digraph')

        graph.set_graphviz_executables(paths)

        self.assertRaises(pydotplus.InvocationException, graph.create) 
開發者ID:carlos-jenkins,項目名稱:pydotplus,代碼行數:10,代碼來源:pydot_unittest.py

示例7: push_top_graph_stmt

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def push_top_graph_stmt(str, loc, toks):
    attrs = {}
    g = None

    for element in toks:
        if (isinstance(element, (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 = pydotplus.Dot(graph_type=element, **attrs)
            attrs['type'] = element

            top_graphs.append(g)

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

        elif isinstance(element, pydotplus.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, (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:carlos-jenkins,項目名稱:pydotplus,代碼行數:48,代碼來源:parser.py

示例8: to_pydot

# 需要導入模塊: import pydotplus [as 別名]
# 或者: from pydotplus import Dot [as 別名]
def to_pydot(N, strict=True):
    """Return a pydot graph from a NetworkX graph N.

    Parameters
    ----------
    N : NetworkX graph
      A graph created with NetworkX

    Examples
    --------
    >>> K5 = nx.complete_graph(5)
    >>> P = nx.nx_pydot.to_pydot(K5)

    Notes
    -----

    """
    import pydotplus
    # set Graphviz graph type
    if N.is_directed():
        graph_type='digraph'
    else:
        graph_type='graph'
    strict=N.number_of_selfloops()==0 and not N.is_multigraph()

    name = N.name
    graph_defaults=N.graph.get('graph',{})
    if name is '':
        P = pydotplus.Dot('', graph_type=graph_type, strict=strict,
                      **graph_defaults)
    else:
        P = pydotplus.Dot('"%s"'%name, graph_type=graph_type, strict=strict,
                      **graph_defaults)
    try:
        P.set_node_defaults(**N.graph['node'])
    except KeyError:
        pass
    try:
        P.set_edge_defaults(**N.graph['edge'])
    except KeyError:
        pass

    for n,nodedata in N.nodes_iter(data=True):
        str_nodedata=dict((k,make_str(v)) for k,v in nodedata.items())
        p=pydotplus.Node(make_str(n),**str_nodedata)
        P.add_node(p)

    if N.is_multigraph():
        for u,v,key,edgedata in N.edges_iter(data=True,keys=True):
            str_edgedata=dict((k,make_str(v)) for k,v in edgedata.items())
            edge=pydotplus.Edge(make_str(u), make_str(v),
                    key=make_str(key), **str_edgedata)
            P.add_edge(edge)

    else:
        for u,v,edgedata in N.edges_iter(data=True):
            str_edgedata=dict((k,make_str(v)) for k,v in edgedata.items())
            edge=pydotplus.Edge(make_str(u),make_str(v),**str_edgedata)
            P.add_edge(edge)
    return P 
開發者ID:SpaceGroupUCL,項目名稱:qgisSpaceSyntaxToolkit,代碼行數:62,代碼來源:nx_pydot.py


注:本文中的pydotplus.Dot方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。