miso-flow
LicenseBSD3-style (see the file LICENSE)
Safe HaskellNone
LanguageHaskell2010

Miso.Flow.Utils.Graph

Description

Pure port of utils/graph.ts from @xyflow/system.

Synopsis

Documentation

getOutgoers :: NodeId -> [Node n] -> [Edge e] -> [Node n] Source #

Nodes connected to the given node as the target of an edge.

getIncomers :: NodeId -> [Node n] -> [Edge e] -> [Node n] Source #

Nodes connected to the given node as the source of an edge.

getNodePositionWithOrigin :: Node n -> NodeOrigin -> XYPosition Source #

Position of a node adjusted by its origin.

getNodesBounds :: [Node n] -> NodeOrigin -> Rect Source #

Bounding box containing all given nodes (no lookup: positions are taken from the user nodes and the given origin).

getNodesBoundsWithLookup :: [NodeId] -> NodeLookup n -> Rect Source #

Bounding box containing all the given node ids, resolved through a NodeLookup so sub-flow (parent) positions are correct. Unknown ids are skipped.

getInternalNodesBounds :: (InternalNode n -> Bool) -> NodeLookup n -> Rect Source #

Bounding box of the internal nodes matching the filter.

getNodesInside Source #

Arguments

:: NodeLookup n 
-> Rect 
-> Transform 
-> Bool

partially: also include nodes only partially inside

-> Bool

exclude non-selectable nodes

-> [InternalNode n] 

Internal nodes inside (or partially inside) the given rect.

getConnectedEdges :: [Node n] -> [Edge e] -> [Edge e] Source #

Edges where either endpoint is one of the given nodes.

getFitViewNodes :: NodeLookup n -> FitViewOptions -> NodeLookup n Source #

Which nodes participate in a fit-view; port of getFitViewNodes.

fitViewportFor Source #

Arguments

:: NodeLookup n 
-> Double

width

-> Double

height

-> Double

min zoom

-> Double

max zoom

-> FitViewOptions 
-> Maybe Viewport 

Pure core of fitViewport: computes the viewport for fitting the given nodes into width × height. Returns Nothing for an empty lookup (the effectful caller then leaves the viewport unchanged).

calculateNodePosition Source #

Arguments

:: NodeId 
-> XYPosition

next (absolute) position

-> NodeLookup n 
-> NodeOrigin 
-> Maybe CoordinateExtent

global node extent

-> Maybe (XYPosition, XYPosition) 

Next position of a node given its extent, parent and origin; port of calculateNodePosition. Returns (position, positionAbsolute); Nothing when the node is missing from the lookup.

getElementsToRemove Source #

Arguments

:: [NodeId]

nodes to remove

-> [EdgeId]

edges to remove

-> [Node n]

all nodes

-> [Edge e]

all edges

-> ([Node n], [Edge e]) 

Which of the requested nodes and edges may actually be deleted; port of getElementsToRemove (without the async onBeforeDelete hook — run your own check on the result instead).