Module

Hylograph.Flow.Render.Measures

Package
purescript-hylograph-flow-render
Repository
afcondon/purescript-hylograph-flow-render

Measures of a drawn graph, whoever laid it out: the scoreboard of an earlier layout trial, here so that every engine is scored by one rule.

Every measure is a function of a Drawn and nothing else: node boxes, each edge as the straight pieces it is drawn along, and the boxes of the open groups' outlines with their members. drawnOf makes a Drawn of any Layout, each route by Hylograph.Flow.Render.Route.flatten: a straight piece is its two ends, a cubic curve is curveSteps (12) straight pieces. So a ribbon, a dog-leg and a spline are measured by one rule, and no engine's own counts are used. A Drawn can also be made by hand, which is how the measures are held to figures worked out on paper. (The trial read each edge back from its SVG path; the pieces are the same, so its figures stand.)

THE MEASURES, exactly, as the trial stated them.

  • crossings: the number of points at which a piece of one edge's line properly crosses a piece of another edge's: each piece's two ends strictly on opposite sides of the other piece. Touching does not count: two edges that leave one point, an edge that turns exactly on another, and two edges that run along one line (a shared trunk) cross nowhere. Two edges that cross twice count twice.
  • edgeLength: the sum of the lengths of every edge's line, pixels.
  • bends: total turning, in right angles: the sum over every interior point of every line of the angle turned there, divided by 90 degrees. An orthogonal route scores one for each corner; a curve scores by how far it swings (an S that reaches 45 degrees and comes back scores one), and a straight line nothing.
  • extent: the box round every node, outline and edge point; area is its width times its height, in pixels squared, and aspect its width over its height.
  • nodeOverlaps: the pairs of node boxes with more than a touch in common (more than skin, 1 pixel, each way).
  • edgesThroughNodes: the pairs of an edge and a node that is neither of its ends, where the edge's line enters the node's box drawn in by skin on every side.
  • outlineTrespasses: the pairs of an edge and an outline where neither end of the edge is a member of the outline's group and the edge's line enters the outline's box drawn in by skin. (An edge with an end inside must cross the outline, and is not counted.)
  • strangersIn: the pairs of an outline and a node that is no member of it and is in its box or partly in it: the general law (Hylograph.Flow.Render.Laws.strangers), counted.
  • unrouted: the edges with no line (fewer than two points). No route of a Layout is such (Route cannot be), so of a layout this is 0 unless a route's points are all one point; it is here for a Drawn made otherwise. An edge an engine left out altogether is the laws' to report (Placed), and unplaced counts them.

Time to lay out is not here: it is measured by whoever runs the layout.

#Drawn Source

type Drawn = { edges :: Array DrawnEdge, nodes :: Array Box, outlines :: Array DrawnOutline }

#DrawnEdge Source

type DrawnEdge = { from :: Int, points :: Array Point, to :: Int }

from, to: the places of the edge's two nodes in nodes.

#DrawnOutline Source

type DrawnOutline = { box :: Box, members :: Array Int }

#Score Source

type Score = { area :: Number, aspect :: Number, bends :: Number, crossings :: Int, edgeLength :: Number, edges :: Int, edgesThroughNodes :: Int, height :: Number, nodeOverlaps :: Int, nodes :: Int, outlineTrespasses :: Int, strangers :: Int, unrouted :: Int, width :: Number }

#drawnOf Source

drawnOf :: forall wire. Layout wire -> Drawn

A layout as drawn: its node boxes in the layout's order, its edges as their routes' straight pieces, its outlines.

#scoreOf Source

scoreOf :: forall wire. Layout wire -> Score

Every measure of a layout.

#crossings Source

#edgeLength Source

#extent Source

#nodeOverlaps Source

#edgesThroughNodes Source

#outlineTrespasses Source

#strangersIn Source

strangersIn :: Drawn -> Int

The pairs of an outline and a node that is no member of it and is in its box or partly in it, to a millionth of a pixel: the count of what Hylograph.Flow.Render.Laws.strangers lists.

#unrouted Source

#unplaced Source

unplaced :: forall wire. Projection wire -> Layout wire -> Int

The edges of a projection that a layout of it gave no place.

#skin Source

skin :: Number

How far inside a box an edge must come to be in it, and how much two boxes must share to overlap: 1 pixel.