vcg.edge.EFAdj
类是用来处理有向图边的类,也可以用于无向图。此类用于存储两个节点之间的边,以及该边的权重值。
__init__(self, source: int, target: int, weight: float) -> None
初始化 EFAdj
对象。
source
(int
),边的起始节点。target
(int
),边的目标节点。weight
(float
),边的权重值。__str__(self) -> str
返回一个表示 EFAdj
对象的字符串。
str
),表示 EFAdj
对象的字符串。source
int
。该属性表示边的起始节点。
target
int
。该属性表示边的目标节点。
weight
float
。该属性表示边的权重值。
from vcg.edge import EFAdj
# 初始化 EFAdj 对象
edge = EFAdj(1, 2, 1.5)
# 打印输出 EFAdj 对象的字符串表示
print(edge)
# 访问 EFAdj 对象的属性
print("Source node:", edge.source)
print("Target node:", edge.target)
print("Weight:", edge.weight)
运行结果:
1 2 1.5
Source node: 1
Target node: 2
Weight: 1.5