获取连接状态 - GetNodeConnectionStatus
函数简介
查询两个节点之间是否存在连接。
返回值:1 表示可以连接;0 表示不能连接;-1 表示节点不存在或图指针无效。
接口名称
GetNodeConnectionStatus
DLL调用
int32_t GetNodeConnectionStatus(int64_t instance, int64_t graphPtr,
char* from, char* to);
参数说明
参数名 | 类型 | 说明 |
---|---|---|
instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
graphPtr | 长整数型 | 图的指针。 |
from | 字符串 | 起始节点名称。 |
to | 字符串 | 目标节点名称。 |
示例
// 创建OLA实例
int64_t instance = CreateCOLAPlugInterFace();
int64_t g = CreateGraphFromCoordinates(instance,
"[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":3,\"y\":4}]",
false, 0.0, true);
// 建立连接
SetNodeConnection(instance, g, "A", "B", true, -1.0);
// 查询连接状态
int32_t st = GetNodeConnectionStatus(instance, g, "A", "B");
printf("status: %d\n", st); // 1
DeleteGraph(instance, g);
DestroyCOLAPlugInterFace(instance);
返回值
1:可以连接;0:不能连接;-1:节点不存在或图指针无效。
注意事项
- 确保 graphPtr 是有效的图指针。
- 节点需已存在于图中。