vcg.edge.Mark
是一个用于图形化表现 VCG 输出文件的 Python 库,其通过在图形中的边缘上添加标记来增强图像的可读性。
vcg.edge.Mark
提供以下方法:
__init__(self, label, attributes=None)
初始化 vcg.edge.Mark
对象。
label
:str,标识该标记的文本attributes
:dict,包含标记的颜色和样式属性。其中,可用的属性如下:
'color'
:str,标记的颜色。默认为红色 ('red'
)。'style'
:str,标记的样式。默认为箭头 ('arrow'
)。build(self, edges)
生成 VCG 输出文件中的标记字符串。
edges
:List[Tuple[int, int, Dict[str, Any]]],图中的边缘列表。每个边缘由源节点 ID,目标节点 ID 和包含边缘属性的字典组成。vcg.edge.Mark
具有以下属性:
label
str,标识该标记的文本。
color
str,标记的颜色。默认为红色 ('red'
)。
style
str,标记的样式。默认为箭头 ('arrow'
)。
import vcg
# 创建一个节点标记
node_mark = vcg.node.Mark('A')
# 创建一个边缘标记
edge_mark = vcg.edge.Mark('label', {'color': 'blue'})
# 生成一个有标记的图像
vcg.draw([node1, node2], [(0, 1, {'label': 'edge1'}), (1, 0, {'label': 'edge2'})], [node_mark, edge_mark])