Module

Hylograph.Forces.Linkage

Package
purescript-hylograph-forces
Repository
afcondon/purescript-hylograph-forces

Links joined to their nodes: what the link force and the directional constraint both start from.

The degree counts and the bias are d3-force 3.0.0's (link.js, initialize; ISC, Copyright 2010-2021 Mike Bostock; see LICENSE).

A link can name its nodes by their place in the node array (joinByPlace) or by an id read off each node (joinById). By place, a link that names a place outside the array is dropped. By id, a link that names an id no node has is an error, with d3's message.

#Endpoints Source

type Endpoints :: Row Type -> Typetype Endpoints row = { source :: Int, target :: Int | row }

A link, by the places of its two nodes in the node array.

#Identified Source

type Identified :: Type -> Row Type -> Typetype Identified id row = { source :: id, target :: id | row }

A link, by the ids of its two nodes.

#Joined Source

type Joined :: Row Type -> Type -> Typetype Joined row link = { bias :: Number, link :: link, source :: Node row, sourceDegree :: Number, target :: Node row, targetDegree :: Number }

A link with its nodes found. The degrees are d3's count: how many links touch each end. bias is d3's count[source] / (count[source] + count[target]): the share of a correction that the target takes, so that the better connected end moves less.

#joinByPlace Source

joinByPlace :: forall row linkRow. Array (Node row) -> Array (Endpoints linkRow) -> Array (Joined row (Endpoints linkRow))

Join links that name their nodes by place. A link naming a place outside the array is dropped.

#joinById Source

joinById :: forall id row linkRow. Ord id => Show id => (Node row -> id) -> Array (Node row) -> Array (Identified id linkRow) -> Either String (Array (Joined row (Identified id linkRow)))

Join links that name their nodes by id: d3's force.id(...). Where two nodes share an id the later one is meant, as in d3. A link whose source or target is no node's id gives d3's error, node not found: <id>.