import { CytoscapeGraph } from "@/components/tutorials/shared/CytoscapeGraph"; import { ExampleLayout } from "@/components/tutorials/shared/ExampleLayout"; import { ExampleSection } from "@/components/tutorials/shared/ExampleSection"; import type { Stylesheet } from "cytoscape"; export default function SetupExample() { // 定义图的元素 const elements = [ // 节点 { data: { id: "a", label: "Node A" } }, { data: { id: "b", label: "Node B" } }, { data: { id: "c", label: "Node C" } }, // 边 { data: { id: "ab", source: "a", target: "b", label: "Edge AB" } }, { data: { id: "bc", source: "b", target: "c", label: "Edge BC" } }, ]; // 定义样式 const style: Stylesheet[] = [ { selector: "node", style: { backgroundColor: "#666", label: "data(label)", textValign: "center", textHalign: "center", width: 60, height: 60, } as any, }, { selector: "edge", style: { width: 3, lineColor: "#ccc", targetArrowColor: "#ccc", targetArrowShape: "triangle", curveStyle: "bezier", label: "data(label)", } as any, }, ]; return (

这是一个简单的 Cytoscape.js 图实例,展示了基本的节点和边的创建。

); }