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


Python Graph.subgraph方法代碼示例

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


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

示例1: draw_SCION_topology

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import subgraph [as 別名]
def draw_SCION_topology(topology_dict, n_labels, l_labels, desc_labels):
    """
    Draws the Scion topology from a topology dictionary
    returned by parse_gen_folder.
    :param dictionary topology_dict: dictionary returned by parse_gen_folder,
            boolean ip_addresses: indicates if node labels are drawn,
            boolean edge_labels: indicates if edge labels are drawn
            dict desc_labels: Dictionary containing labels for ISDs and ASes
    :return Dot graph: graph of the SCION topology
    """
    isd_graphs = {}
    dot = Graph(name='topology', filename='topology.gv', comment='SCION-net')
    ISDs = topology_dict["ISD"]
    # draw each ISD graph
    for ISD in ISDs:
        isd_graphs[ISD] = draw_isd_graph(
            ISD, ISDs[ISD]["AS"], n_labels, l_labels, desc_labels)
    # put all isd graphs into the same graph
    for ISD in isd_graphs:
        dot.subgraph(isd_graphs[ISD])
    # add edges between ISDs
    dot = draw_inter_ISD_edges(dot, ISDs, n_labels)
    return dot
開發者ID:netsec-ethz,項目名稱:scion-web,代碼行數:25,代碼來源:scion_topology_graphviz.py

示例2: plot

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import subgraph [as 別名]
    def plot(self):
        g = Graph(format='png')
        styles = {
            'graph': {
                'rankdir': self.direction,
                'splines': 'line',
                'label': 'Restricted Boltzmann Machine',
                'labelloc': 't', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'edge':{
                'color': 'black',
                # 'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(g, styles)

        vLayer = Graph('cluster_0')
        styles = {
            'graph': {
                'rankdir': 'LR',
                'splines': 'line',
                'label': 'Visible Units',
                'labelloc': 't', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'node': {
                'shape': 'circle',
                'color': 'lightblue3',
                'label': '',
            },
            'edge':{
                'color': 'black',
                'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(vLayer, styles)
        vNodes = ['v%d'%i for i in range(self.numVisible)]
        vNodes[-2] = (vNodes[-2], {'label': '...', 'style': '', 'shape': 'circle', 'color':'white'})
        self.add_nodes(vLayer, vNodes)


        hLayer = Graph('cluster_1')
        styles = {
            'graph': {
                'rankdir': 'LR',
                'splines': 'line',
                'label': 'Hidden Units',
                'labelloc': 'b', ## t: top, b: bottom, c: center
                'labeljust': 'c', ## l: left, r: right, c: center
            },
            'node': {
                'shape': 'circle',
                'color': 'red3',
                'label': '',
            },
            'edge':{
                'color': 'black',
                'constraint': 'false',
                'style': 'filled',
            }
        }
        self.add_styles(hLayer, styles)
        hNodes = ['h%d'%i for i in range(self.numHidden)]
        hNodes[-2] = (hNodes[-2], {'label': '...', 'style': '', 'shape': 'circle', 'color':'white'})
        self.add_nodes(hLayer, hNodes)

        g.subgraph(hLayer)
        g.subgraph(vLayer)
        edges = []
        for vn in vNodes:
            for hn in hNodes:
                if isinstance(vn, tuple):
                    if isinstance(hn, tuple):
                        edges.append(((vn[0], hn[0]), {'style':'invis'}))
                    else:
                        edges.append(((vn[0], hn), {'style': 'invis'}))
                else:
                    if isinstance(hn, tuple):
                        edges.append(((vn, hn[0]), {'style':'invis'}))
                    else:
                        edges.append((vn, hn))
        self.add_edges(g, edges)
        print (g.source)
        g.view()
開發者ID:AlgorithmFan,項目名稱:PlotNeuralNetwork,代碼行數:89,代碼來源:RBM.py

示例3: Graph

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import subgraph [as 別名]
c1 = Graph('cluster_'+class_list[1])
c1.node_attr.update(color=col[1],shape =shp[1])
for key in key_list:
    if m_class[key] == class_list[1]:
        c1.node(key)


c2 = Graph('cluster_'+class_list[2])
c2.node_attr.update(color=col[2],shape =shp[2])
for key in key_list:
    if m_class[key] == class_list[2]:
        c2.node(key)


c3 = Graph('cluster_'+class_list[3])
c3.node_attr.update(color=col[3],shape =shp[3])
for key in key_list:
    if m_class[key] == class_list[3]:
        c3.node(key)
        
## adding subgraphs to main graph
g.subgraph(c0)
g.subgraph(c3)
g.subgraph(c1)
g.subgraph(c2)

## adding edges based on the given condition
for x in combinations(key_list,2):
    if pearsonr(m_ave_values[x[0]],m_ave_values[x[1]])[0] > 0.98:
        g.edge(x[0], x[1], penwidth = str(0.03/float(1-pearsonr(m_ave_values[x[0]],m_ave_values[x[1]])[0])) )
g.view()
開發者ID:mnshgl0110,項目名稱:Bioinformatics2,代碼行數:33,代碼來源:task5.py

示例4: Graph

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import subgraph [as 別名]
#!/usr/bin/env python
# http://www.graphviz.org/Gallery/gradient/g_c_n.html

from graphviz import Graph

g = Graph('G', filename='g_c_n.gv')
g.attr(bgcolor='purple:pink', label='agraph', fontcolor='white')

with g.subgraph(name='cluster1') as c:
    c.attr(fillcolor='blue:cyan', label='acluster', fontcolor='white',
           style='filled', gradientangle='270')
    c.attr('node', shape='box', fillcolor='red:yellow',
           style='filled', gradientangle='90')
    c.node('anode')

g.view()
開發者ID:xflr6,項目名稱:graphviz,代碼行數:18,代碼來源:g_c_n.py

示例5: Graph

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import subgraph [as 別名]
#!/usr/bin/env python
# fdpclust.py - http://www.graphviz.org/content/fdpclust

from graphviz import Graph

g = Graph('G', filename='fdpclust.gv', engine='fdp')

g.node('e')

with g.subgraph(name='clusterA') as a:
    a.edge('a', 'b')
    with a.subgraph(name='clusterC') as c:
        c.edge('C', 'D')

with g.subgraph(name='clusterB') as b:
    b.edge('d', 'f')

g.edge('d', 'D')
g.edge('e', 'clusterB')
g.edge('clusterC', 'clusterB')

g.view()
開發者ID:xflr6,項目名稱:graphviz,代碼行數:24,代碼來源:fdpclust.py


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