Fiaz Technologies
Usage

Add Edges

Learn how to add edges in PyWebflow and understand all available parameters.

Adding an Edge

The add_edge method in PyWebflow allows you to create and connect edges between nodes in your graph.

Usage

wf.add_edge(edge_id, source, target, **kwargs)

Parameters

ParameterTypeDescription
edge_idstrA unique identifier for the edge.
sourcestrThe id of the node where the edge originates.
targetstrThe id of the node where the edge terminates.
animatedOptional[bool]If True, the edge is animated (e.g., a moving flow effect).
dataOptional[Dict]Custom metadata associated with the edge.
styleOptional[Dict]CSS styling properties for the edge.
selectedOptional[bool]If True, the edge starts as selected.
sourceHandleIdOptional[str]ID of the source handle (for multiple connections).
targetHandleIdOptional[str]ID of the target handle (for multiple connections).
interactionWidthOptional[int]Defines the interaction width for edge selection.
sourceXOptional[float]X-coordinate of the source node’s connection point.
sourceYOptional[float]Y-coordinate of the source node’s connection point.
targetXOptional[float]X-coordinate of the target node’s connection point.
targetYOptional[float]Y-coordinate of the target node’s connection point.
sourcePositionOptional[str]Defines where the edge originates ("top", "bottom", "left", "right").
targetPositionOptional[str]Defines where the edge connects ("top", "bottom", "left", "right").
labelOptional[str]A text label for the edge.
labelStyleOptional[Dict]CSS styling properties for the label.
labelShowBgOptional[bool]If True, shows a background behind the label.
labelBgStyleOptional[Dict]CSS styling properties for the label background.
labelBgPaddingOptional[List[int]]Padding for the label background (e.g., [5, 5]).
labelBgBorderRadiusOptional[int]Border radius for the label background.
markerStartOptional[str]Defines the starting marker (e.g., arrow).
markerEndOptional[str]Defines the ending marker (e.g., arrow).
pathOptionsOptional[Dict]Additional options for customizing the edge path.

Example

wf.add_edge(
    edge_id="edge1",
    source="node1",
    target="node2",
    animated=True,
    style={"stroke": "blue", "strokeWidth": 2},
    label="Data Flow",
    labelStyle={"fontSize": 14, "fill": "black"},
    markerEnd="arrow"
)

This example adds an animated edge between "node1" and "node2" with:

  • Custom styling (blue color, 2px width)
  • A label "Data Flow" with a custom font size
  • An arrow marker at the end

Additional Notes

  • sourceHandleId and targetHandleId are useful for nodes with multiple connection points.
  • markerStart and markerEnd allow arrows or other markers on the edges.
  • Use animated=True to create a dynamic flow effect.
Edit on GitHub

Last updated on

On this page