class Rubyvis::Layout::Arc

Implements a layout for arc diagrams. An arc diagram is a network visualization with a one-dimensional layout of nodes, using circular arcs to render links between nodes. For undirected networks, arcs are rendering on a single side; this makes arc diagrams useful as annotations to other two-dimensional network layouts, such as rollup, matrix or table layouts. For directed networks, links in opposite directions can be rendered on opposite sides using directed(true).

<p>Arc layouts are particularly sensitive to node ordering; for best results, order the nodes such that related nodes are close to each other. A poor (e.g., random) order may result in large arcs with crossovers that impede visual processing. A future improvement to this layout may include automatic reordering using, e.g., spectral graph layout or simulated annealing.

This visualization technique is related to that developed by M. Wattenberg, Arc Diagrams: Visualizing Structure in Strings in IEEE InfoVis, 2002. However, this implementation is limited to simple node-link networks, as opposed to structures with hierarchical self-similarity (such as strings). As with other network layouts, three mark prototypes are provided:<ul>

<li>node - for rendering nodes; typically a Rubyvis::Dot <li>link - for rendering links; typically a Rubyvis::Line <li>node_label - for rendering node labels; typically a Rubyvis::Label

</ul> For more details on how this layout is structured and can be customized, see Rubyvis::Layout::Network



Whether this arc digram is directed (bidirectional); only applies to non-radial orientations. By default, arc digrams are undirected, such that all arcs appear on one side. If the arc digram is directed, then forward links are drawn on the conventional side (the same as as undirected links–right, left, bottom and top for left, right, top and bottom, respectively), while reverse links are drawn on the opposite side.


The orientation. The default orientation is “bottom”, which means that nodes will be positioned from bottom-to-top in the order they are specified in the nodes property. The following orientations are supported:<ul>

<li>left - left-to-right. <li>right - right-to-left. <li>top - top-to-bottom. <li>bottom - bottom-to-top. <li>radial - radially, starting at 12 o’clock and proceeding clockwise.</ul>

Public Class Methods

defaults() click to toggle source

Default properties for arc layouts. By default, the orientation is “bottom”.

# File lib/rubyvis/layout/arc.rb, line 157
def self.defaults
new() click to toggle source
# File lib/rubyvis/layout/arc.rb, line 40
def initialize
  @_interpolate=nil # cached interpolate
  @_directed=nil # cached directed
  @_reverse=nil # cached reverse
  that=self {|_p|
      that._reverse != (that._directed or (s.breadth < t.breadth)) ? [s, t] : [t, s]
  }).interpolate(lambda{ that._interpolate})

Public Instance Methods

sort(f=nil,&block) click to toggle source

Specifies an optional sort function. The sort function follows the same comparator contract required by Rubyvis::Dom::Node#sort. Specifying a sort function provides an alternative to sort the nodes as they are specified by the nodes property; the main advantage of doing this is that the comparator function can access implicit fields populated by the network layout, such as the link_degree.

<p>Note that arc diagrams are particularly sensitive to order. This is referred to as the seriation problem, and many different techniques exist to find good node orders that emphasize clusters, such as spectral layout and simulated annealing.

# File lib/rubyvis/layout/arc.rb, line 173
def sort(f=nil,&block)