Skip to content

@graphty/graphty-element / Edge / Edge

Class: Edge

Defined in: src/Edge.ts:45

Represents a directed edge between two nodes in the graph visualization. Handles rendering of edge lines, arrow heads/tails, and labels with support for various styles.

Constructors

Constructor

new Edge(graph, srcNodeId, dstNodeId, styleId, data, opts): Edge

Defined in: src/Edge.ts:99

Creates a new Edge instance connecting two nodes.

Parameters

graph

The parent graph or graph context

GraphContext | Graph

srcNodeId

NodeIdType

The ID of the source node

dstNodeId

NodeIdType

The ID of the destination node

styleId

EdgeStyleId

The style ID to apply to this edge

data

AdHocData

Custom data associated with the edge

opts

EdgeOpts = {}

Optional configuration options

Returns

Edge

Properties

algorithmResults

algorithmResults: AdHocData

Defined in: src/Edge.ts:54


arrowHeadText

arrowHeadText: RichTextLabel | null = null

Defined in: src/Edge.ts:63


arrowMesh

arrowMesh: AbstractMesh | null = null

Defined in: src/Edge.ts:57


arrowTailMesh

arrowTailMesh: AbstractMesh | null = null

Defined in: src/Edge.ts:58


arrowTailText

arrowTailText: RichTextLabel | null = null

Defined in: src/Edge.ts:64


changeManager

changeManager: ChangeManager

Defined in: src/Edge.ts:69


data

data: AdHocData

Defined in: src/Edge.ts:53


dstId

dstId: NodeIdType

Defined in: src/Edge.ts:49


dstNode

dstNode: Node

Defined in: src/Edge.ts:51


id

id: string

Defined in: src/Edge.ts:50


label

label: RichTextLabel | null = null

Defined in: src/Edge.ts:62


mesh

mesh: AbstractMesh | PatternedLineMesh

Defined in: src/Edge.ts:56


opts

opts: EdgeOpts

Defined in: src/Edge.ts:47


parentGraph

parentGraph: GraphContext | Graph

Defined in: src/Edge.ts:46


ray

ray: Ray

Defined in: src/Edge.ts:61


srcId

srcId: NodeIdType

Defined in: src/Edge.ts:48


srcNode

srcNode: Node

Defined in: src/Edge.ts:52


styleId

styleId: EdgeStyleId

Defined in: src/Edge.ts:59


styleUpdates

styleUpdates: AdHocData

Defined in: src/Edge.ts:55

Methods

addCalculatedStyle()

addCalculatedStyle(cv): void

Defined in: src/Edge.ts:236

Adds a calculated style value to this edge.

Parameters

cv

CalculatedValue

The calculated value to add

Returns

void


getInterceptPoints()

getInterceptPoints(): InterceptPoint

Defined in: src/Edge.ts:845

Calculates ray intersection points with source and destination node meshes. Used to position edges at node surfaces rather than centers.

Returns

InterceptPoint

Intersection points for source, destination, and adjusted endpoint


transformArrowCap()

transformArrowCap(): EdgeLine

Defined in: src/Edge.ts:591

Calculates and applies transformations for arrow head and tail meshes. Adjusts edge line endpoints to create gaps for arrows.

Returns

EdgeLine

Edge line positions adjusted for arrow placement


transformEdgeMesh()

transformEdgeMesh(srcPoint, dstPoint): void

Defined in: src/Edge.ts:568

Transforms the edge mesh to position it between source and destination points. Handles different mesh types (solid, patterned, 2D, bezier).

Parameters

srcPoint

Vector3

The source point position

dstPoint

Vector3

The destination point position

Returns

void


update()

update(): void

Defined in: src/Edge.ts:244

Updates the edge's visual representation based on current node positions and style changes. Performs dirty checking to skip updates when nodes haven't moved.

Returns

void


updateRays()

static updateRays(g): void

Defined in: src/Edge.ts:527

Updates ray directions for all edges in the graph to enable accurate mesh intersections.

Parameters

g

The graph or graph context containing the edges

GraphContext | Graph

Returns

void


updateStyle()

updateStyle(styleId): void

Defined in: src/Edge.ts:362

Updates the edge's style by changing its styleId and recreating visual elements.

Parameters

styleId

EdgeStyleId

The new style ID to apply

Returns

void