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


Python AGraph.node_attr['shape']方法代码示例

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


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

示例1: plot

# 需要导入模块: from pygraphviz import AGraph [as 别名]
# 或者: from pygraphviz.AGraph import node_attr['shape'] [as 别名]
def plot(table_names=None):
    """
    Plot relationships between columns and tables using Graphviz.

    Parameters
    ----------
    table_names : iterable of str, optional
        Names of UrbanSim registered tables to plot.
        Defaults to all registered tables.

    Returns
    -------
    graph : pygraphviz.AGraph
        PyGraphviz graph object.

    """
    if not table_names:
        # Default to all registered tables.
        table_names = simulation.list_tables()

    graph = AGraph(directed=True)
    graph.graph_attr['fontname'] = 'Sans'
    graph.graph_attr['fontsize'] = 28
    graph.node_attr['shape'] = 'box'
    graph.node_attr['fontname'] = 'Sans'
    graph.node_attr['fontcolor'] = 'blue'
    graph.edge_attr['weight'] = 2

    # Add each registered table as a subgraph with columns as nodes.
    for table_name in table_names:
        subgraph = graph.add_subgraph(name='cluster_' + table_name,
                                      label=table_name, fontcolor='red')
        table = simulation.get_table(table_name)
        for column_name in table.columns:
            full_name = table_name + '.' + column_name
            subgraph.add_node(full_name, label=column_name)

    # Iterate over computed columns to build nodes.
    for key, wrapped_col in simulation._COLUMNS.items():
        table_name = key[0]
        column_name = key[1]

        # Combine inputs from argument names and argument default values.
        args = list(wrapped_col._argspec.args)
        if wrapped_col._argspec.defaults:
            default_args = list(wrapped_col._argspec.defaults)
        else:
            default_args = []
        inputs = args[:len(args) - len(default_args)] + default_args

        # Create edge from each input column to the computed column.
        for input_name in inputs:
            full_name = table_name + '.' + column_name
            graph.add_edge(input_name, full_name)

    graph.layout(prog='dot')
    return graph
开发者ID:UDST,项目名称:spandex,代码行数:59,代码来源:sim.py

示例2: Copyright

# 需要导入模块: from pygraphviz import AGraph [as 别名]
# 或者: from pygraphviz.AGraph import node_attr['shape'] [as 别名]
"""
#    Copyright (C) 2006 by 
#    Aric Hagberg <[email protected]>
#    Dan Schult <[email protected]>
#    Manos Renieris, http://www.cs.brown.edu/~er/
#    Distributed with BSD license.     
#    All rights reserved, see LICENSE for details.
__author__ = """Aric Hagberg ([email protected])"""

from pygraphviz import AGraph

A = AGraph()

# set some default node attributes
A.node_attr['style'] = 'filled'
A.node_attr['shape'] = 'circle'
A.node_attr['fixedsize'] = 'true'
A.node_attr['fontcolor'] = '#FFFFFF'

# make a star in shades of red
for i in range( 16 ):
    A.add_edge( 0, i )
    n = A.get_node( i )
    n.attr['fillcolor'] = "#%2x0000" % ( i * 16 )
    n.attr['height'] = "%s" % ( i / 16.0 + 0.5 )
    n.attr['width'] = "%s" % ( i / 16.0 + 0.5 )

print A.string() # print to screen
A.write( "star.dot" ) # write to simple.dot
print "Wrote star.dot"
A.draw( 'star.png', prog="circo" ) # draw to png using circo
开发者ID:kelidas,项目名称:scratch,代码行数:33,代码来源:star.py


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