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


Python Graph.format方法代碼示例

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


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

示例1: graph_data

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import format [as 別名]
def graph_data(pkg_name):
    if not pkg_name:
        abort(404)

    filepath = os.path.join(cache_dir, pkg_name.lower())
    if not os.path.exists(filepath + '.png'):
        nodes, edges = reqs_graph(pkg_name)

        if not nodes:
            return redirect(url_for('static', filename='img/blank.png'))

        dot = Graph()
        dot.format = 'png'
        dot.node('0', nodes[0], fillcolor='#fbb4ae', style='filled', shape='box')
        for i, pkg_name in enumerate(nodes[1:]):
            dot.node(str(i+1), pkg_name, fillcolor='#ccebc5', style='filled')

        dot.edges([
            [str(i[0]), str(i[1])]
            for i in edges
        ])

        dot.render(filepath)

    return send_file(filepath + '.png')
開發者ID:sargo,項目名稱:python-package-requirements,代碼行數:27,代碼來源:main.py

示例2: generateGraph

# 需要導入模塊: from graphviz import Graph [as 別名]
# 或者: from graphviz.Graph import format [as 別名]
def generateGraph():
	G = Graph(
		engine = 'dot',
		filename = 'Btrfs-Graph.dot',
		name = 'BRTFS-Browser',
		comment = 'https://github.com/Zo0MER/BRTFS-Browser.git',
		graph_attr = {'rankdir': 'RL',
						'charset':'utf-8',
						'bgcolor':'#eeeeee',
						'labelloc':'t', 
						'splines':'compound',
						'nodesep':'0.7',
						'ranksep':'5'
					},
		node_attr = {'fontsize': '18.0',
					'shape':'box'
		}
	)

	#node with title and hyperlink on github
	G.node('meta', 
		label = 'Btrfs-debug-tree \nhttps://github.com/Zo0MER/BRTFS-Browser.git', 
		href = 'https://github.com/Zo0MER/BRTFS-Browser.git',
		fontcolor = '#4d2600',
		fontsize = '30.0'
		)

	first = inode[0]
	inode.remove(inode[0])

	if (inode):
		#link first item ROOT_TREE_DIR INODE_ITEM, INODE_REF with all INODE_ITEM EXTEND_DATA
		for pair in inode:
			G.edge(''.join([str(x) for x in first]), ''.join([str(x) for x in pair]))
	else:
		G.node(first)

	#save *.dot and others
	pathout = enterPath.get()
	filenameout = enterFilename.get()

	if (filenameout):
		filenameout = filenameout + '.gv.dot'
	else:
		filenameout = "btrfs-graph"

	G.filename = filenameout + '.gv.dot'
	G.directory = pathout

	G.save()
	for t in types:
		G.format = t
		G.render()
開發者ID:kekdck,項目名稱:BRTFS-Browser,代碼行數:55,代碼來源:btrfs_graph.py


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