Files
lan-manager/web/node_modules/@antv/graphlib/docs/classes/GraphWithEvent.md
openclaw 0a5f6a8047 Initial commit: Lan-manager project code
- Go backend (server/)
- Frontend (web/, server/static/)
- Database and deployment files
- Scripts and docs

Co-Authored-By: 狸花猫/Claude-Qwen3.6-Plus 🐾
2026-04-20 00:52:58 +08:00

26 KiB
Raw Blame History

@antv/graphlib / Exports / GraphWithEvent

Class: GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Type parameters

Name Type
NodeIDType string
NodeType Record<string, any>
EdgeType Record<string, any>
GraphType string

Hierarchy

  • Graph<NodeIDType, NodeType, EdgeType, GraphType>

    GraphWithEvent

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>(options?)

Type parameters

Name Type
NodeIDType string
NodeType Record<string, any>
EdgeType Record<string, any>
GraphType string

Parameters

Name Type
options GraphOption

Inherited from

Graph.constructor

Defined in

Graph/index.ts:112

Properties

eventPool

Private eventPool: Record<string, Function[]> = {}

description a pool of event listeners.

description.zh-cn 事件监听器池。

Defined in

Graph/event.ts:15


label

Optional label: GraphType

description Label for this graph itself

description.zh-cn 图本身的标签label

default undefined

Inherited from

Graph.label

Defined in

Graph/index.ts:80


fromJSON

Static fromJSON: <NodeIDType, NodeType, EdgeType, GraphType>(json: JSONGraph<NodeIDType, NodeType, EdgeType, GraphType>) => Graph<NodeIDType, NodeType, EdgeType, GraphType> = read

Type declaration

▸ <NodeIDType, NodeType, EdgeType, GraphType>(json): Graph<NodeIDType, NodeType, EdgeType, GraphType>

description read a graph from JSON.

description.zh-cn 从 JSON 读取图。

Type parameters
Name Type
NodeIDType string
NodeType Record<string, any>
EdgeType Record<string, any>
GraphType string
Parameters
Name Type
json JSONGraph<NodeIDType, NodeType, EdgeType, GraphType>
Returns

Graph<NodeIDType, NodeType, EdgeType, GraphType>

Inherited from

Graph.fromJSON

Defined in

Graph/index.ts:762

Methods

appendEvent

appendEvent(type, callback): void

description Add an event listener.

description.zh-cn 添加事件监听器。

Parameters

Name Type
type GraphEventType
callback Function

Returns

void

Defined in

Graph/event.ts:21


children

children(node?): undefined | NodeIDType[]

description get graph's or node's children

description.zh-cn 获取图或者节点的字节点

Parameters

Name Type
node? NodeIDType

Returns

undefined | NodeIDType[]

Inherited from

Graph.children

Defined in

Graph/index.ts:408


edge

edge(edgeObj): undefined | EdgeType

description Get edge between two nodes by edge object

description.zh-cn 从edgeObj获得两个节点中的一条边

Parameters

Name Type
edgeObj Object
edgeObj.name? any
edgeObj.v NodeIDType
edgeObj.w NodeIDType

Returns

undefined | EdgeType

Inherited from

Graph.edge

Defined in

Graph/index.ts:660


edgeCount

edgeCount(): number

description Count the edge in graph

description.zh-cn 返回图中边的数量

Returns

number

number

Inherited from

Graph.edgeCount

Defined in

Graph/index.ts:579


edgeFromArgs

edgeFromArgs(v, w, name?): undefined | EdgeType

description Get edge between two nodes

description.zh-cn 获得两个节点中的一条边

Parameters

Name Type
v NodeIDType
w NodeIDType
name? any

Returns

undefined | EdgeType

Inherited from

Graph.edgeFromArgs

Defined in

Graph/index.ts:650


edges

edges(): DefaultEdgeType<NodeIDType, EdgeType>[]

description get all edges object in graph

description.zh-cn 获得图中所有的边对象

Returns

DefaultEdgeType<NodeIDType, EdgeType>[]

Inherited from

Graph.edges

Defined in

Graph/index.ts:716


emitEvent

emitEvent(type, ...args): void

description trigger an event.

description.zh-cn 触发事件。

Parameters

Name Type
type GraphEventType
...args any[]

Returns

void

Defined in

Graph/event.ts:46


filterNodes

filterNodes(filter): Graph<NodeIDType, NodeType, EdgeType, GraphType>

description Using node filter to create a new graph;

description.zh-cn 过滤节点并创建一个新图

Parameters

Name Type
filter (node: NodeIDType) => boolean

Returns

Graph<NodeIDType, NodeType, EdgeType, GraphType>

Inherited from

Graph.filterNodes

Defined in

Graph/index.ts:480


graph

graph(): GraphType

description Get Graph label (Identity for graph)

description.zh-cn 获取图的标识符

Returns

GraphType

stirng | undefined

Inherited from

Graph.graph

Defined in

Graph/index.ts:212


hasEdge

hasEdge(v, w, name?): boolean

description Does two nodes has a specific edge

description.zh-cn 两个节点之间是否存在确定的一条边

Parameters

Name Type
v NodeIDType
w NodeIDType
name? any

Returns

boolean

Inherited from

Graph.hasEdge

Defined in

Graph/index.ts:672


hasNode

hasNode(node): boolean

description Is the node in graph

description.zh-cn 判断节点是否在图中

Parameters

Name Type
node NodeIDType

Returns

boolean

Inherited from

Graph.hasNode

Defined in

Graph/index.ts:329


inEdges

inEdges(v, u?): undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

description get edges that target at the node (could be from certain node)

description.zh-cn 获取所有指向节点的边,可以指定来源节点

Parameters

Name Type
v NodeIDType
u? NodeIDType

Returns

undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

Inherited from

Graph.inEdges

Defined in

Graph/index.ts:725


isCompound

isCompound(): boolean

description Is this graph a compound graph;

description.zh-cn 这个图是否是复合图(包含嵌套节点的图)

default false

Returns

boolean

Inherited from

Graph.isCompound

Defined in

Graph/index.ts:194


isDirected

isDirected(): boolean

description Is the graph directed or not

description.zh-cn 这个图是否是有向图

default true

Returns

boolean

Inherited from

Graph.isDirected

Defined in

Graph/index.ts:180


isLeaf

isLeaf(node): boolean

description Is the node a leaf node

description.zh-cn 判断节点是否为叶子节点

Parameters

Name Type
node NodeIDType

Returns

boolean

Inherited from

Graph.isLeaf

Defined in

Graph/index.ts:467


isMultigraph

isMultigraph(): boolean

description Is this graph contains more than one graph data

description.zh-cn 这个图是否包含多个图

default false

Returns

boolean

Inherited from

Graph.isMultigraph

Defined in

Graph/index.ts:187


neighbors

neighbors(node): undefined | NodeIDType[]

description get node's neighbors

description.zh-cn 获取节点的所有邻居节点

Parameters

Name Type
node NodeIDType

Returns

undefined | NodeIDType[]

Inherited from

Graph.neighbors

Defined in

Graph/index.ts:454


node

node(n): undefined | NodeType

description get node label

description.zh-cn 获取节点的标签

Parameters

Name Type
n NodeIDType

Returns

undefined | NodeType

Inherited from

Graph.node

Defined in

Graph/index.ts:240


nodeCount

nodeCount(): number

description Count the nodes in graph

description.zh-cn 计算图中所有节点的数量

Returns

number

number

Inherited from

Graph.nodeCount

Defined in

Graph/index.ts:234


nodeDegree

nodeDegree(node): number

description Count the total edges of node

description.zh-cn 计算节点的所有边的数量

Parameters

Name Type
node NodeIDType

Returns

number

Inherited from

Graph.nodeDegree

Defined in

Graph/index.ts:796


nodeEdges

nodeEdges(v, w?): undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

description get edges between two nodes

description.zh-cn 获取两个节点间所有的节点

Parameters

Name Type
v NodeIDType
w? NodeIDType

Returns

undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

Inherited from

Graph.nodeEdges

Defined in

Graph/index.ts:755


nodeInDegree

nodeInDegree(node): number

description Count the in edges of node

description.zh-cn 计算节点的入边的数量

Parameters

Name Type
node NodeIDType

Returns

number

Inherited from

Graph.nodeInDegree

Defined in

Graph/index.ts:772


nodeOutDegree

nodeOutDegree(node): number

description Count the out edges of node

description.zh-cn 计算节点的出边的数量

Parameters

Name Type
node NodeIDType

Returns

number

Inherited from

Graph.nodeOutDegree

Defined in

Graph/index.ts:784


nodes

nodes(): NodeIDType[]

description Return all nodes in graph

description 返回图中所有节点

Returns

NodeIDType[]

Inherited from

Graph.nodes

Defined in

Graph/index.ts:247


outEdges

outEdges(w, u?): undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

description get edges that from the node (could target at certain node)

description.zh-cn 获取所有来源于节点的边,可以指定目标节点

Parameters

Name Type
w NodeIDType
u? NodeIDType

Returns

undefined | DefaultEdgeType<NodeIDType, EdgeType>[]

Inherited from

Graph.outEdges

Defined in

Graph/index.ts:740


parent

parent(node): undefined | NodeIDType

description Find node's parent (compond graph only)

description.zh-cn 寻找节点的父节点 (只有复合图可以使用)

Parameters

Name Type
node NodeIDType

Returns

undefined | NodeIDType

Inherited from

Graph.parent

Defined in

Graph/index.ts:347


predecessors

predecessors(node): undefined | NodeIDType[]

description get node's predecessors

description.zh-cn 获取节点的所有上游节点

Parameters

Name Type
node NodeIDType

Returns

undefined | NodeIDType[]

Inherited from

Graph.predecessors

Defined in

Graph/index.ts:432


removeEdge

removeEdge(v_, w_, name?): GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Parameters

Name Type
v_ NodeIDType
w_ NodeIDType
name? any

Returns

GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Overrides

Graph.removeEdge

Defined in

Graph/event.ts:73


removeEdgeObj

removeEdgeObj(__namedParameters): this

description remove a specific edge by edge object

description.zh-cn 删除一条边

Parameters

Name Type
__namedParameters Object
__namedParameters.name? any
__namedParameters.v NodeIDType
__namedParameters.w NodeIDType

Returns

this

Inherited from

Graph.removeEdgeObj

Defined in

Graph/index.ts:708


removeEvent

removeEvent(type, callback): void

description remove an event listener.

description.zh-cn 移除事件监听器。

Parameters

Name Type
type GraphEventType
callback Function

Returns

void

Defined in

Graph/event.ts:32


removeNode

removeNode(node): GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Parameters

Name Type
node NodeIDType

Returns

GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Overrides

Graph.removeNode

Defined in

Graph/event.ts:61


setDefaultEdgeLabel

setDefaultEdgeLabel(newDefault): this

description Set function that generate default label for edge, if param is non-function value then default label will always be this value;

description.zh-cn 设置默认获取边Label的方法如果传入不是函数的那么默认label 的值只会是传入值

Parameters

Name Type
newDefault any

Returns

this

Inherited from

Graph.setDefaultEdgeLabel

Defined in

Graph/index.ts:565


setDefaultNodeLabel

setDefaultNodeLabel(newDefault): this

description Set function that generate default label for node, if param is non-function value then default label will always be this value;

description.zh-cn 设置默认获取节点Label的方法如果传入不是函数的那么默认label 的值只会是传入值

Parameters

Name Type Description
newDefault any (node) => label | label

Returns

this

this

Inherited from

Graph.setDefaultNodeLabel

Defined in

Graph/index.ts:220


setEdge

setEdge(v_, w_, value?, name?): GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Parameters

Name Type
v_ NodeIDType
w_ NodeIDType
value? any
name? string

Returns

GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Overrides

Graph.setEdge

Defined in

Graph/event.ts:67


setEdgeObj

setEdgeObj(edgeObj, value?): this

Parameters

Name Type
edgeObj DefaultEdgeType<NodeIDType, EdgeType>
value? EdgeType

Returns

this

Inherited from

Graph.setEdgeObj

Defined in

Graph/index.ts:623


setGraph

setGraph(label?): this

description Set Graph label (Identity for graph)

description.zh-cn 设置图的标识符

Parameters

Name Type
label? GraphType

Returns

this

Inherited from

Graph.setGraph

Defined in

Graph/index.ts:202


setNode

setNode(node, value?): GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Parameters

Name Type
node NodeIDType
value? NodeType

Returns

GraphWithEvent<NodeIDType, NodeType, EdgeType, GraphType>

Overrides

Graph.setNode

Defined in

Graph/event.ts:55


setNodes

setNodes(nodes, value?): this

description Set nodes or add nodes in batch

description.zh-cn 批量设置或者创建节点

Parameters

Name Type
nodes NodeIDType[]
value? NodeType

Returns

this

Inherited from

Graph.setNodes

Defined in

Graph/index.ts:318


setParent

setParent(node, parent?): this

description Set node's parent(default is the graph) (compond graph only)

description.zh-cn 设置节点的父节点,如果没有给定,父节点为这个图 (只有复合图可以使用)

Parameters

Name Type
node NodeIDType
parent? NodeIDType

Returns

this

Inherited from

Graph.setParent

Defined in

Graph/index.ts:373


setPath

setPath(edges, value?): this

description Add edge using a sorted node array ([a,b,c] => a->b b->c c->a)

description.zh-cn 用一系列节点来定义一群边([a,b,c] => a->b b->c c->a)

Parameters

Name Type
edges NodeIDType[]
value? any

Returns

this

Inherited from

Graph.setPath

Defined in

Graph/index.ts:634


sinks

sinks(): NodeIDType[]

description Return all sink nodes in graph

description 返回图中所有终点节点出度为0

Returns

NodeIDType[]

Inherited from

Graph.sinks

Defined in

Graph/index.ts:261


source

source(edge): NodeIDType

description Get the source of edge

description.zh-cn 获取边的源节点

Parameters

Name Type
edge DefaultEdgeType<NodeIDType, EdgeType>

Returns

NodeIDType

Inherited from

Graph.source

Defined in

Graph/index.ts:804


sources

sources(): NodeIDType[]

description Return all source nodes in graph

description 返回图中所有源头节点入度为0

Returns

NodeIDType[]

Inherited from

Graph.sources

Defined in

Graph/index.ts:254


successors

successors(node): undefined | NodeIDType[]

description get node's successors

description.zh-cn 获取节点的所有下游节点

Parameters

Name Type
node NodeIDType

Returns

undefined | NodeIDType[]

Inherited from

Graph.successors

Defined in

Graph/index.ts:443


target

target(edge): NodeIDType

description Get the target of edge

description.zh-cn 获取边的目标节点

Parameters

Name Type
edge DefaultEdgeType<NodeIDType, EdgeType>

Returns

NodeIDType

Inherited from

Graph.target

Defined in

Graph/index.ts:810


toJSON

toJSON(): JSONGraph<NodeIDType, NodeType, EdgeType, GraphType>

Returns

JSONGraph<NodeIDType, NodeType, EdgeType, GraphType>

Inherited from

Graph.toJSON

Defined in

Graph/index.ts:764