我正在尝试使用库图形工具来创建一个新的对象图形。我特别想要一些学生节点和其他教授节点
在我编写的以下代码中,我无法添加学生/教授的顶点
文档https://graph-tool.skewed.de/static/doc/quickstart.html#property-maps解释了我必须使用类PropertyMap,这对我来说很奇怪
有人能给我解释一下怎么用吗?谢谢
这是我的密码:
from graph_tool.all import *
class Student:
def __init__(self, name):
self.name = name
class Professor:
def __init__(self, name):
self.name = name
g = Graph()
s = Student("Luke")
p = Professor("Adam")
print(s.name)
print(p.name)
首先你需要把顶点添加到图中
为用户类型创建属性映射
这将是节点的属性。您可以创建所需数量,然后设置其用户类型 例如:
现在可以使用属性绘制图形
相关问题 更多 >
编程相关推荐