goyalarchit / elm-dagre / Dagre

This module is the core module that implements the sugiyama style graph drawing based on popular js library dagrejs.

This module assumes graphs are defined using elm-community/graph module.

Return Types


type alias GraphLayout =
{ width : Basics.Float
, height : Basics.Float
, coordDict : Dict Graph.NodeId Utils.Coordinates
, controlPtsDict : Dict Utils.Edge (List Graph.NodeId) 
}

This type represents the record returned by the runLayout function.

  1. The width and height fields represent the width and height of graph.
  2. The coordDict contains the dictionary that maps node-ids to the coordinates on cartesian plane.
  3. The controlPtsDict contains a dictionary that maps edges to its control/bend points (list of node-ids)

API

runLayout : List Attributes.Attribute -> Graph n e -> GraphLayout

This is the main function that computes the layout for a graph using sugiyama style graph drawing.

This function takes a list of Dagre Attributes and a graph and outputs the layout.

-- simpleGraph = Graph from Readme (or any graph)
runLayout [] simpleGraph

All the computed coordinates lie between (0,0) and (width,height). In simple terms, you can set viewBox 0 0 width height in the svg.

default configurations

defaultConfig : Attributes.Config

This represents the default configuration of runLayout function. For more details about configuring a layout please see Dagre.Attributes