Hylograph.Data.Graph
- Package
- purescript-hylograph-selection
- Repository
- afcondon/purescript-hylograph-selection
#GraphModel Source
type GraphModel node link = { links :: Array link, maps :: GraphMaps node link, nodes :: Array node }Generic graph model parameterized by node and link types Provides efficient access to nodes and links via multiple indexes
#GraphConfig Source
type GraphConfig node link = { getLinkSource :: link -> NodeID, getLinkTarget :: link -> NodeID, getNodeId :: node -> NodeID }Configuration for building a graph model Provides functions to extract IDs from nodes and links
#buildGraphModel Source
buildGraphModel :: forall node link. GraphConfig node link -> Array node -> Array link -> GraphModel node linkBuild a complete graph model from arrays of nodes and links
This function constructs all the necessary indexes for efficient graph queries. It ensures that:
- All nodes are indexed by ID
- Links are indexed by both source and target
- A set of all node IDs is maintained
Example:
let config = { getNodeId: _.id
, getLinkSource: _.source
, getLinkTarget: _.target
}
let graph = buildGraphModel config nodes links
#emptyGraphModel Source
emptyGraphModel :: forall node link. GraphModel node linkCreate an empty graph model
#addNode Source
addNode :: forall node link. GraphConfig node link -> node -> GraphModel node link -> GraphModel node linkAdd a node to an existing graph model Note: Does not update links; use buildGraphModel for complete rebuilds
#addLink Source
addLink :: forall node link. GraphConfig node link -> link -> GraphModel node link -> GraphModel node linkAdd a link to an existing graph model Note: Does not validate that source/target nodes exist
#getNode Source
getNode :: forall node link. NodeID -> GraphModel node link -> Maybe nodeGet a node by its ID
#getNodesByIds Source
getNodesByIds :: forall node link. Array NodeID -> GraphModel node link -> Array nodeGet multiple nodes by their IDs Returns only the nodes that exist (filters out missing IDs)
#getLinksFrom Source
getLinksFrom :: forall node link. NodeID -> GraphModel node link -> Array linkGet all links originating from a node (by source)
#getLinksTo Source
getLinksTo :: forall node link. NodeID -> GraphModel node link -> Array linkGet all links pointing to a node (by target)
#getAllNodes Source
getAllNodes :: forall node link. GraphModel node link -> Array nodeGet all nodes in the graph
#getAllLinks Source
getAllLinks :: forall node link. GraphModel node link -> Array linkGet all links in the graph
#toDataGraph Source
toDataGraph :: forall node link. GraphConfig node link -> GraphModel node link -> Graph NodeID nodeConvert GraphModel to Data.Graph format (from purescript-graphs package)
This enables interoperability with existing code that uses Data.Graph. The conversion extracts outgoing link targets for each node.
Example:
let graphModel = buildGraphModel config nodes links
let dataGraph = toDataGraph config graphModel
-- Now use with Data.Graph functions
- Modules
- Data.
DependencyGraph - Hylograph.
AST - Hylograph.
Axis. Axis - Hylograph.
Brush - Hylograph.
Brush. FFI - Hylograph.
Brush. Types - Hylograph.
Classify - Hylograph.
Data. Graph - Hylograph.
Data. Graph. Algorithms - Hylograph.
Data. Node - Hylograph.
Data. Tree - Hylograph.
Expr. Animation - Hylograph.
Expr. Attr - Hylograph.
Expr. Datum - Hylograph.
Expr. Expr - Hylograph.
Expr. Friendly - Hylograph.
Expr. Integration - Hylograph.
Expr. Interpreter. CodeGen - Hylograph.
Expr. Interpreter. Eval - Hylograph.
Expr. Interpreter. Meta - Hylograph.
Expr. Interpreter. PureSVG - Hylograph.
Expr. Interpreter. SVG - Hylograph.
Expr. Path - Hylograph.
Expr. Path. Generators - Hylograph.
Expr. Sugar - Hylograph.
Expr. Units - Hylograph.
HATS - Hylograph.
HATS. Friendly - Hylograph.
HATS. InterpreterTick - Hylograph.
HATS. Transitions - Hylograph.
Interaction. Brush - Hylograph.
Interaction. Coordinated - Hylograph.
Interaction. Pointer - Hylograph.
Interaction. Zoom - Hylograph.
Internal. Attribute - Hylograph.
Internal. Behavior. FFI - Hylograph.
Internal. Behavior. Types - Hylograph.
Internal. Capabilities. Selection - Hylograph.
Internal. Capabilities. Transition - Hylograph.
Internal. FFI - Hylograph.
Internal. Selection. Join - Hylograph.
Internal. Selection. Operations - Hylograph.
Internal. Selection. Operations. Conversions - Hylograph.
Internal. Selection. Operations. Helpers - Hylograph.
Internal. Selection. Operations. Selection - Hylograph.
Internal. Selection. Query - Hylograph.
Internal. Selection. Types - Hylograph.
Internal. Transition. FFI - Hylograph.
Internal. Transition. Manager - Hylograph.
Internal. Transition. Scene - Hylograph.
Internal. Transition. Types - Hylograph.
Internal. Types - Hylograph.
Interpreter. D3 - Hylograph.
Interpreter. English - Hylograph.
Interpreter. Mermaid - Hylograph.
Interpreter. MetaAST - Hylograph.
Interpreter. SemiQuine - Hylograph.
Interpreter. SemiQuine. TreeToCode - Hylograph.
Interpreter. SemiQuine. Types - Hylograph.
Render - Hylograph.
Scale - Hylograph.
Scale. FP - Hylograph.
Shape. Arc - Hylograph.
Shape. Pie - Hylograph.
Shape. Polygon - Hylograph.
Tooltip - Hylograph.
Transform - Hylograph.
TreeDSL - Hylograph.
TreeDSL. ShapeTree - Hylograph.
Unified - Hylograph.
Unified. Attribute - Hylograph.
Unified. DataDSL - Hylograph.
Unified. Display - Hylograph.
Unified. Examples - Hylograph.
Unified. Join - Hylograph.
Unified. Sugar