pygraphviz 学习笔记

pygraphviz 学习笔记
摘要由CSDN通过智能技术生成

pygraphviz 学习笔记
个人认为python第三方库中 graphviz比 pygraphviz好,以下是之前学习pygraphviz的笔记:
G.add_path(nlist)
按nlist增加路径
G.clear() Remove all nodes, edges, and attributes from the graph.
G.degree(nbunch=None, with_labels=False)
Return the degree of nodes given in nbunch container. 这里的degree指点的连接数量。
Using optional with_labels=True returns a dictionary keyed by node with value set to the degree.

degree_iter(nbunch=None, indeg=True, outdeg=True)
Return an iterator over the degree of the nodes given in nbunch container.
Returns pairs of (node,degree).

delete_edge(u, v=None, key=None)
Remove edge between nodes u and v from the graph.
With optional key argument will only remove an edge matching (u,v,key).
delete_edges_from(ebunch)
Remove edges from ebunch (a container of edges).
delete_node(n)
Remove the single node n.
Attempting to remove a node that isn’t in the graph will produce an error.

delete_subgraph(name) Remove subgraph with given name.
property directed G.directed Return True if graph is directed or False if not.
draw(path=None, format=None, prog=None, args=‘’)
Output graph to path in specified format.
An attempt will be made to guess the output format based on the file extension of path. If that fails, then the format parameter will be used.
Note, if path is a file object returned by a call to os.fdopen(), then the method for discovering the
format will not work. In such cases, one should explicitly set the format parameter; otherwise, it will default to ‘dot’.
If path is None, the result is returned as a Bytes object.
Formats (not all may be available on every system depending on how Graphviz was built)
‘canon’, ‘cmap’, ‘cmapx’, ‘cmapx_np’, ‘dia’, ‘dot’, ‘fig’, ‘gd’, ‘gd2’, ‘gif’, ‘hpgl’, ‘imap’,
‘imap_np’, ‘ismap’, ‘jpe’, ‘jpeg’, ‘jpg’, ‘mif’, ‘mp’, ‘pcl’, ‘pdf’, ‘pic’, ‘plain’, ‘plain-ext’,
‘png’, ‘ps’, ‘ps2’, ‘svg’, ‘svgz’, ‘vml’, ‘vmlz’, ‘vrml’, ‘vtx’, ‘wbmp’, ‘xdot’, ‘xlib’
If prog is not specified and the graph has positions (see layout()) then no additional graph positioning will be performed.
Optional prog=[‘neato’|’dot’|’twopi’|’circo’|’fdp’|’nop’] will use specified graphviz layout method.

adjacent adj.相邻; 邻近的; 与…毗连的;
[例句]The house adjacent to ours is under repairs. 与我家相邻的房子正在修缮。

from_string(string)
Load a graph from a string in dot format.
Overwrites any existing graph.
To make a new graph from a string use

get_edge(u, v, key=None) Return an edge object (Edge) corresponding to edge (u,v).
get_node(n) Return a node object (Node) corresponding to node n.

get_subgraph(name) Return existing subgraph with specified name or None if it doesn’t exist.
has_edge(u, v=None, key=None) Return True an edge u-v is in the graph or False if not.

has_neighbor(u, v, key=None) Return True if u has an edge to v or False if not.
has_node(n) Return True if n is in the graph or False if not.

in_degree(nbunch=None, with_labels=False) 入度数
Return the in-degree of nodes given in nbunch container.
Using optional with_labels=True returns a dictionary keyed by node with value set to the degree.

in_degree_iter(nbunch=None)
Return an iterator over the in-degree of the nodes given in nbunch container.
Returns pairs of (node,degree).

in_edges(nbunch=None, keys=False)
Return list of in edges in the graph. If the optional nbunch (container of nodes) only in edges
adjacent to nodes in nbunch will be returned.

in_edges_iter(nbunch=None, keys=False)
Return iterator over out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable results. Use in_edges() as an alternative.

in_neighbors(n) Return list of predecessor nodes of n.
is_directed() Return True if graph is directed or False if not.
is_strict() Return True if graph is strict or False if not.Strict graphs do not allow parallel edges or self loops.
is_undirected() Return True if graph is undirected or False if not.
iterdegree(nbunch=None, indeg=True, outdeg=True) Return an iterator over the degree of the nodes given in nbunch container.Returns pairs of (node,degree).
iteredges(nbunch=None, keys=False)
Return iterator over edges in the graph.
If the optional nbunch (container of nodes) only edges adjacent to nodes in nbunch will be returned.
Note: modifying the graph structure while iterating over edges may produce unpredictable results. Use edges() as an alternative.

iterindegree(nbunch=None)
Return an iterator over the in-degree of the nodes given in nbunch container.
Returns pairs of (node,degree).

iterinedges(nbunch=None, keys=False)
Return iterator over out edges in the graph.
If the optional nbunch (container of nodes) only out edges adjacent to nodes in nbunch will be returned.
Note: modifying the

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值