Math & Numbers
Dijkstra 最短路径的手算辅助工具:输入 1–30 条边(每行:起点、终点、权重)与起点/终点,默认无向、可切换有向。逐轮记录“定居哪个节点、距离多少、每次松弛如何更新临时距离表”,平局按字典序取最小节点名,日志与教科书演算完全一致;负权重按业务拒绝,终点不可达作为合法结果报告。经典例:A-B 4、A-C 2、B-C 5、B-D 10、C-E 3、D-E 4、D-F 11、E-F 8,从 A 到 F → 最短距离 13,路径 A→C→E→F。
用三种语言从你的代码中调用此工具。
curl -X POST 'https://api.elysiatools.com/zh/api/tools/graph-shortest-path' \
-H 'Content-Type: application/json' \
-d '{"edges":"A B 4\nA C 2\nB C 5\nB D 10\nC E 3\nD E 4\nD F 11\nE F 8","source":"A","target":"F","directed":false,"decimalPlaces":2}'以 JSON 形式 POST 提交输入参数。文件类型参数需先单独上传。
POST https://api.elysiatools.com/zh/api/tools/graph-shortest-path| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| edges | textarea | 是 | One edge per line: two node names (1–8 letters/digits) and a non-negative weight. |
| source | text | 是 | — |
| target | text | 是 | — |
| directed | checkbox | 否 | When checked, each edge only leads from the first node to the second; otherwise the graph is undirected. |
| decimalPlaces | number | 否 | — |
将此工具加入你的 Model Context Protocol 服务,让 AI 智能体可以列出并调用它。
将以下内容加入你的 MCP 客户端配置:
{
"mcpServers": {
"elysiatools-graph-shortest-path": {
"name": "graph-shortest-path",
"description": "Dijkstra 最短路径的手算辅助工具:输入 1–30 条边(每行:起点、终点、权重)与起点/终点,默认无向、可切换有向。逐轮记录“定居哪个节点、距离多少、每次松弛如何更新临时距离表”,平局按字典序取最小节点名,日志与教科书演算完全一致;负权重按业务拒绝,终点不可达作为合法结果报告。经典例:A-B 4、A-C 2、B-C 5、B-D 10、C-E 3、D-E 4、D-F 11、E-F 8,从 A 到 F → 最短距离 13,路径 A→C→E→F。",
"baseUrl": "https://api.elysiatools.com/mcp/sse?toolId=graph-shortest-path",
"command": "",
"args": [],
"env": {},
"isActive": true,
"type": "sse"
}
}
}连接到 SSE 端点后,列出已开放的工具:
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}通过工具 id 调用,参数由其参数表构建:
{
"jsonrpc": "2.0",
"id": 2,
"method": "tools/call",
"params": {
"name": "graph-shortest-path",
"arguments": {
"edges": "A B 4\nA C 2\nB C 5\nB D 10\nC E 3\nD E 4\nD F 11\nE F 8",
"source": "A",
"target": "F",
"directed": false,
"decimalPlaces": 2
}
}
}有问题或反馈?请联系 [email protected]
文本结果
{
"result": "Processed text content",
"error": "Error message (optional)",
"message": "Notification message (optional)",
"metadata": {
"key": "value"
}
}