anchor.diff:              |> directedGraph.AppendChild
   
           // Add the rules/states/transitions to the graph
  -        compiledSpec.CompiledRules
  -        |> Map.iter (fun ruleId compiledRule ->
  +        let categoryColors =
  +            Palette.random compiledSpec.CompiledRules.Count
  +        (0, compiledSpec.CompiledRules)
  +        ||> Map.fold (fun ruleIndex ruleId compiledRule ->
               // Add a category for this rule.
               let ruleCategory =
                   dgmlDoc.CreateElement ("Category", directedGraph.NamespaceURI)
  
positive.code:             let idAttr = dgmlDoc.CreateAttribute "Id"
              ruleCategory.Attributes.Append idAttr |> ignore
              idAttr.Value <- ruleId
  
              // Add the nodes for this rule's DFA.
              let dfaStateCount = compiledRule.Dfa.Transitions.VertexCount
  
negative.code: // DGML (for Visual Studio)
  // dot (for graphviz)
  
  /// Functions for generating color palettes.
  // Reference : http://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
  [<RequireQualifiedAccess>]
  module private Palette =
      open System.Drawing
  
      /// The conjugate of the golden ratio.
      let private phi_conj = ((1.0 + sqrt 5.0) / 2.0) - 1.0
  
      //
      let private colorFromHSV (hue : float, saturation : float, brightness : float) : Color =
          // Preconditions
          if hue < 0.0 || hue > 360.0 then
              invalidArg "hue" "The hue must be between 0.0 and 360.0 degrees."
          elif saturation < 0.0 || saturation > 1.0 then
              invalidArg "saturation" "The saturation must be in the range [0.0, 1.0]."
          elif brightness < 0.0 || brightness > 1.0 then
              invalidArg "brightness" "The brightness value must be in the range [0.0, 1.0]."
  
          let chroma = saturation * brightness
          
          let r', g', b' =
              let hue' = hue / 60.0
              let x =
                  chroma * (1.0 - abs ((hue' % 2.0) - 1.0))
  
              if hue' < 0.0 then
                  // This shouldn't ever happen, but just to be sure...
                  0.0, 0.0, 0.0
              elif hue' < 1.0 then
                  chroma, x, 0.0
              elif hue' < 2.0 then
                  x, chroma, 0.0
              elif hue' < 3.0 then
                  0.0, chroma, x
              elif hue' < 4.0 then
                  0.0, x, chroma
              elif hue' < 5.0 then
                  x, 0.0, chroma
              else // x >= 5 && x < 6
                  chroma, 0.0, x
  
          let m = brightness - chroma
  
          Color.FromArgb (
              int ((r' + m) * 255.0),
              int ((g' + m) * 255.0),
              int ((b' + m) * 255.0))
  
      /// Returns a randomly-generated color palette
      /// with the specified number of colors.
      let random count =
          // Preconditions
          // TODO : Count must be non-negative.
  
          // TODO : If the count is zero return an empty array.
  
          let rng = System.Random ()
          // Create the random hue value for each color.
          Array.init count <| fun _ -> rng.NextDouble ()
          |> Array.map (fun hue ->
              // The saturation and brightness values can be tweaked as desired.
              let h = (hue + phi_conj) % 1.0
              colorFromHSV (h * 360.0, 0.5, 0.95))
  
  
  [<RequireQualifiedAccess>]
  module Dgml =
      open System.Xml
      open System.Xml.Linq
      open LanguagePrimitives
  
      (* TODO :   Apply styles to the start state of each rule (perhaps some distinct
                  background color which is the same for the start states of all rules);
                  apply a style, e.g., thicker border stroke, to final (accepting) states. *)
  
      //
      let inline private dfaStateUniqueNodeId (ruleId : RuleIdentifier) (dfaStateId : DfaStateId) =
  