Transforms a graph node with x, y and size into an
axis-aligned square.

@param  {object} A graph node with at least a point (x, y) and a size.
@return {object} A square: two points (x1, y1), (x2, y2) and height.
433322
function(n) {
      return {
        x1: n.x - n.size,
        y1: n.y - n.size,
        x2: n.x + n.size,
        y2: n.y - n.size,
        height: n.size * 2
      };
    }
197842
function(x, y) {
    var type = (this._target || this).type;
    return type == 'radial' || type == 'circle' ?
      this.attr('r', new SVG.Number(x)) :
      this.rx(x).ry(y == null ? x : y)
  }
450852
function (x, y, width, height) {

                // create a dummy element
                var clipRect = this.createElement(),
                  isObj = isObject(x);

                // mimic a rectangle with its style object for automatic updating in attr
                return extend(clipRect, {
                    members: [],
                    left: (isObj ? x.x : x) + 1,
                    top: (isObj ? x.y : y) + 1,
                    width: (isObj ? x.width : width) - 1,
                    height: (isObj ? x.height : height) - 1,
                    getCSS: function (wrapper) {
                        var element = wrapper.element,
                          nodeName = element.nodeName,
                          isShape = nodeName === 'shape',
                          inverted = wrapper.inverted,
                          rect = this,
                          top = rect.top - (isShape ? element.offsetTop : 0),
                          left = rect.left,
                          right = left + rect.width,
                          bottom = top + rect.height,
                          ret = {
                              clip: 'rect(' +
                              mathRound(inverted ? left : top) + 'px,' +
                              mathRound(inverted ? bottom : right) + 'px,' +
                              mathRound(inverted ? right : bottom) + 'px,' +
                              mathRound(inverted ? top : left) + 'px)'
                          };

                        // issue 74 workaround
                        if (!inverted && docMode8 && nodeName === 'DIV') {
                            extend(ret, {
                                width: right + PX,
                                height: bottom + PX
                            });
                        }
                        return ret;
                    },

                    // used in attr and animation to update the clipping of all members
                    updateClipping: function () {
                        each(clipRect.members, function (member) {
                            if (member.element) { // Deleted series, like in stock/members/series-remove demo. Should be removed from members, but this will do.
                                member.css(clipRect.getCSS(member));
                            }
                        });
                    }
                });

            }
413368
function(node, geometry) {
        var resolution = this.getResolution();
    
        node.style.left = (((geometry.x - this.featureDx)/resolution - this.offset.x) | 0) + "px";
        node.style.top = ((geometry.y/resolution - this.offset.y) | 0) + "px";
        node.style.width = ((geometry.width/resolution) | 0) + "px";
        node.style.height = ((geometry.height/resolution) | 0) + "px";
        
        return node;
    }
967536
function (x, y, v) {
            var tileX = Math.floor(x),
                tileY = Math.floor(y);
            var ret = v || new me.Vector2d();

            if (this.staggerX) {
                ret.y = tileY * (this.tileheight + this.sidelengthy);
                if (this.doStaggerX(tileX)) {
                    ret.y += this.rowheight;
                }
                ret.x = tileX * this.columnwidth;
            } else {
                ret.x = tileX * (this.tilewidth + this.sidelengthx);
                if (this.doStaggerY(tileY)) {
                    ret.x += this.columnwidth;
                }
                ret.y = tileY * this.rowheight;
            }

            return ret;
        }
1356153
function(matrix4x4) {
            var newpolygons = this.polygons.map(function(p) {
                return p.transform(matrix4x4);
            });
            var result = CSG.fromPolygons(newpolygons);
            result.properties = this.properties._transform(matrix4x4);
            result.isRetesselated = this.isRetesselated;
            return result;
        }
906915
function (node) {
        var newNode = node.clone();
        var clonedNodesMap = {};
        function buildNodesMap(sNode, tNode) {
            clonedNodesMap[sNode.__uid__] = tNode;

            for (var i = 0; i < sNode._children.length; i++) {
                var sChild = sNode._children[i];
                var tChild = tNode._children[i];
                buildNodesMap(sChild, tChild);
            }
        }
        buildNodesMap(node, newNode);

        newNode.traverse(function (newChild) {
            if (newChild.skeleton) {
                newChild.skeleton = newChild.skeleton.clone(clonedNodesMap);
            }
            if (newChild.material) {
                newChild.material = newChild.material.clone();
            }
        });

        return newNode;
    }
1133902
function simpleSizeForMultiGraphs(graph) {
  var nodes = graph.nodes(),
      size = 0,
      i,
      l;

  for (i = 0, l = nodes.length; i < l; i++) {
    size += graph.outNeighbors(nodes[i]).length;
    size += graph.undirectedNeighbors(nodes[i]).length / 2;
  }

  return size;
}
280662
function(node) {
        // we need to use the old Format.GML parser since we do not know the 
        // geometry name
        if (!this.gmlFormat) {
            this.gmlFormat = new OpenLayers.Format.GML();
        }
        var feature = this.gmlFormat.parseFeature(node);
        var geometry, bounds = null;
        if (feature) {
            geometry = feature.geometry && feature.geometry.clone();
            bounds = feature.bounds && feature.bounds.clone();
            feature.destroy();
        }
        return {geometry: geometry, bounds: bounds};
    }
98931
function KDE( canvas, width, height, left, top ) {

		var graph, data, area, rug, edges, axes, annotations, title, text;

		// [1] Instantiate a new graph generator and configure:
		graph = xfig.graph( canvas )
			.width( width )
			.height( height )
			.position({
				'left': left,
				'top': top
			})
			.xMin( 0 )
			.xMax( 1 )
			.yMin( 0 );

		// Create the graph:
		graph.create( 'kde' );

		// Get data:
		d3.json( 'data/kde.data.json', function ( error, json ) {

			var max;

			// [2] Instantiate a new data generator and configure:
			data = xfig.data( json )
				.accessors( 'x', function ( d ) {
					return d[ 0 ];
				})
				.accessors( 'y', function ( d ) {
					return d[ 1 ];
				});

			// Format the data and calculate the KDE:
			data.format( [ 'x', 'y' ] )
				.kde(
					function ( d ) {
						return d[ 1 ];
					}, 0, 1
				);

			// Bind the data instance to the graph:
			max = data.max( function ( d ) {
				return d[ 1 ];
			});
			max += max * 0.05;
			graph.data( data )
				.yMax( max );

			// [3] Instantiate a new area chart generator and configure:
			area = xfig.area( graph )
				.labels( [ 'data 0' ] );

			// Create the area chart:
			area.create();

			// [4] Instantiate a new data generator and configure:
			data = xfig.data( json )
				.accessors( 'x', function ( d ) {
					return d[ 0 ];
				})
				.accessors( 'y', function ( d ) {
					return d[ 1 ];
				});

			// Format the data:
			data.format( [ 'x', 'y' ] )
				.extract( function ( d ) {
					return d[ 1 ];
				});

			// Bind the data instance to the graph:
			graph.data( data );

			// [5] Instantiate a new rug chart generator and configure:
			rug = xfig.rug( graph )
				.labels( [ 'data 0' ] );

			// Create the rug chart:
			rug.create();

			// [6] Instantiate a new axes generator and configure:
			axes = xfig.axes( graph )
				.yLabel( 'density' );

			// Create the axes:
			axes.create();

			// [7] Instantiate a new annotations generator and configure:
			annotations = xfig.annotations( graph );

			// Create the annotations element:
			annotations.create();

			// [7.1] Instantiate a new title instance and configure:
			title = annotations.title()
				.top( -30 )
				.left( 250 );

			// Add a (sub)title:
			title.create( 'KDE' );

			// [7.2] Instantiate a new text instance and configure:
			text = annotations.text()
				.width( 200 )
				.height( 100 )
				.top( 50 )
				.left( 310 );

			// Add a text annotation:
			text.create( 'This is another text annotation, which may run multiple lines.' );

		});

	}
283157
function graph_pnode(node, node_class, leaf_class, height){
    this.node = node;
    this.height = height;
    this.leaf_class = leaf_class;
    this.connector_shown = false;

    var node_elem = document.createElement("div");
    if (node.is_leaf()) {
        node_elem.appendChild(document.createTextNode(node.label));
        node_elem.className = leaf_class;
    } else {
        node_elem.title = node.label;
        node_elem.className = node_class;
    }

    node_elem.node_id = node.id;
    this.node_elem = node_elem;
}
144303
function(node) {
            var nodeList = this.getElementsByTagNameNS(node, this.internalns,
                                                       "coordinates");
            var coords = [];
            if(nodeList.length > 0) {
                var coordString = nodeList[0].firstChild.nodeValue;
                coordString = coordString.replace(this.regExes.removeSpace, "");
                coords = coordString.split(",");
            }

            var point = null;
            if(coords.length > 1) {
                // preserve third dimension
                if(coords.length == 2) {
                    coords[2] = null;
                }
                point = new OpenLayers.Geometry.Point(coords[0], coords[1],
                                                      coords[2]);
            } else {
                throw "Bad coordinate string: " + coordString;
            }
            return point;
        }
867527
function normalizePoint (point) {
            return {
                x: point.x * canvas.width,
                y: point.y * canvas.height
            };
        }
1139763
function(node) {
        return({
            x: parseFloat(node.getAttributeNS(null, "cx")),
            y: parseFloat(node.getAttributeNS(null, "cy"))
        });
    }
365646
function( pointA, pointB ) {

	        return { x: pointB.x - pointA.x, y: -( pointB.y - pointA.y ) };
	    }
1016750
function indegree(node){
    var degree = 0;
    function check(v){
      if(v === node){
        degree++;
      }
    }
    Object.keys(edges).forEach(function (u){
      edges[u].forEach(check);
    });
    return degree;
  }
127549
function _normalize(nodes) {
  // Set layout
  var farthestY = 0;
  nodes.forEach(function (d) {
    d.y = d.depth * -_layout.depthSpacing;
    if(d.y < farthestY) {
      farthestY = d.y;
    }
  });

  farthestY -= PADDING;
  nodes.forEach(function (d) {
    d.y -= farthestY;
  });

  //Remove space occupied by dummy
  var rootChildren = _treeData.get('children'),
      rootChildCount = rootChildren.length,
      dummyIndex,
      i;

  if(rootChildCount % 2 === 0) {
    dummyIndex = rootChildren.indexOf(_treeData.get('dummy'));
    if(dummyIndex >= rootChildCount / 2) {
      for(i = 0; i < dummyIndex; i++) {
        rootChildren[i].x = rootChildren[i + 1].x;
        rootChildren[i].y = rootChildren[i + 1].y;
      }
    }
    else {
      for(i = rootChildCount - 1; i > dummyIndex; i--) {
        rootChildren[i].x = rootChildren[i - 1].x;
        rootChildren[i].y = rootChildren[i - 1].y;
      }
    }
  }

  // Put all single vertex outputs in-line with the vertex node
  // So that they are directly below the respective vertex in vertical layout
  nodes.forEach(function (node) {
    if(node.type === DataProcessor.types.OUTPUT &&
        node.get('vertex.outputs.length') === 1 &&
        !node.get('vertex.outEdgeIds.length') &&
        node.get('treeParent.x') !== node.get('x')
    ) {
      node.x = node.get('vertex.x');
    }
  });
}