| License | BSD3-style (see the file LICENSE) |
|---|---|
| Safe Haskell | None |
| Language | Haskell2010 |
Miso.Flow.Utils.Graph
Description
Pure port of utils/graph.ts from @xyflow/system.
Synopsis
- getOutgoers :: NodeId -> [Node n] -> [Edge e] -> [Node n]
- getIncomers :: NodeId -> [Node n] -> [Edge e] -> [Node n]
- getNodePositionWithOrigin :: Node n -> NodeOrigin -> XYPosition
- getNodesBounds :: [Node n] -> NodeOrigin -> Rect
- getNodesBoundsWithLookup :: [NodeId] -> NodeLookup n -> Rect
- getInternalNodesBounds :: (InternalNode n -> Bool) -> NodeLookup n -> Rect
- getNodesInside :: NodeLookup n -> Rect -> Transform -> Bool -> Bool -> [InternalNode n]
- getConnectedEdges :: [Node n] -> [Edge e] -> [Edge e]
- getFitViewNodes :: NodeLookup n -> FitViewOptions -> NodeLookup n
- fitViewportFor :: NodeLookup n -> Double -> Double -> Double -> Double -> FitViewOptions -> Maybe Viewport
- calculateNodePosition :: NodeId -> XYPosition -> NodeLookup n -> NodeOrigin -> Maybe CoordinateExtent -> Maybe (XYPosition, XYPosition)
- getElementsToRemove :: [NodeId] -> [EdgeId] -> [Node n] -> [Edge e] -> ([Node n], [Edge e])
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.
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.
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.
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).