当前位置: 首页>>代码示例>>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;未经允许,请勿转载。