Skip to content

添加坐标节点 - AddCoordinateNode

函数简介

向现有图添加或更新一个坐标节点,可按阈值将新节点连接到现有节点,并可选择使用欧几里得距离作为权重。

接口名称

AddCoordinateNode

DLL调用

c
int32_t AddCoordinateNode(int64_t instance, int64_t graphPtr, char* name, double x, double y, bool connectToExisting, double maxDistance, bool useEuclideanDistance);

参数说明

参数名类型说明
instance长整数型OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。
graphPtr长整数型图的指针,由 CreateGraph 或 CreateGraphFromCoordinates 返回。
name字符串节点名称,若已存在则更新其坐标。
x双精度浮点数X 坐标。
y双精度浮点数Y 坐标。
connectToExisting整数型是否连接到现有节点,默认 true。
maxDistance双精度浮点数最大连接距离阈值,默认无穷大。
useEuclideanDistance整数型是否使用欧几里得距离作为边权重,默认 true。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    int ret = ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr);
}
csharp
using OLAPlug;

var ola = new OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates(@"[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]", true, 200.0, true);
if (graphPtr != 0) {
    int ret = ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr);
}
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
graph_ptr = ola.CreateGraphFromCoordinates(r'[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]', True, 200.0, True)
if graph_ptr != 0:
    ret = ola.AddCoordinateNode(graph_ptr, "D", 200, 50, True, 150.0, True)
    ola.DeleteGraph(graph_ptr)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr);
}
cpp
var ola = com("OlaPlug.OlaSoft")
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr)
}
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr)
End If
text
.局部变量 ola, OLAPlug
ola.创建 ()
long graphPtr = ola.CreateGraphFromCoordinates(“[{\“name\“:\“A\“,\“x\“:0,\“y\“:0},{\“name\“:\“B\“,\“x\“:100,\“y\“:0},{\“name\“:\“C\“,\“x\“:50,\“y\“:80}]“, true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph (graphPtr)
.如果真结束
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr);
}
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr)
}
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
long graphPtr = ola.CreateGraphFromCoordinates("[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", true, 200.0, true);
if (graphPtr != 0) {
    ola.AddCoordinateNode(graphPtr, "D", 200, 50, true, 150.0, true);
    ola.DeleteGraph(graphPtr);
}

原生 DLL 调用

cpp
long instance = CreateCOLAPlugInterFace();
long graphPtr = CreateGraphFromCoordinates(instance, "[{\"name\":\"A\",\"x\":0,\"y\":0},{\"name\":\"B\",\"x\":100,\"y\":0},{\"name\":\"C\",\"x\":50,\"y\":80}]", 1, 200.0, 1);
if (graphPtr != 0) {
    AddCoordinateNode(instance, graphPtr, "D", 200, 50, 1, 150.0, 1);
    DeleteGraph(instance, graphPtr);
}
csharp
using System.Runtime.InteropServices;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();

long instance = CreateCOLAPlugInterFace();
long graphPtr = CreateGraphFromCoordinates(instance, @"[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]", 1, 200.0, 1);
if (graphPtr != 0) {
    AddCoordinateNode(instance, graphPtr, "D", 200, 50, 1, 150.0, 1);
    DeleteGraph(instance, graphPtr);
}
python
from ctypes import CDLL, c_int, c_int64

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
instance = ola.CreateCOLAPlugInterFace()
long graphPtr = CreateGraphFromCoordinates(instance, b'[{"name":"A","x":0,"y":0},{"name":"B","x":100,"y":0},{"name":"C","x":50,"y":80}]', 1, 200.0, 1);
if (graphPtr != 0) {
    AddCoordinateNode(instance, graphPtr, "D", 200, 50, 1, 150.0, 1);
    DeleteGraph(instance, graphPtr);
}

返回值

返回值说明
1成功。
0失败。

注意事项

项目说明
graphPtr 是有效的图指针确保 graphPtr 是有效的图指针。
如果节点名称已存在如果节点名称已存在,会更新坐标信息。
connectToExisting 为 trueconnectToExisting 为 true 时,新节点会连接到距离小于 maxDistance 的现有节点。