(function(){function t(e){$.extend(this,t.defaults,e)}t.defaults={cols:3,spacing:15};t.prototype={create:function(t,e){this._vertices={};this._edges={};this.width=t.width;this.height=t.height;var i=this.model.vertices;var h=this.cols||1;var s=this.width/h;var r=0;var o=0,n=0;for(var g=0;g<i.length;g++){var d=i[g];var a=this.getVertexSize(d);this._vertices[d.id]={pos:{left:t.left+s*r,top:o,width:Math.min(s-this.spacing,a.width),height:a.height}};if(a.height>n){n=a.height}r=(r+1)%h;if(r==0){o+=n+this.spacing;n=0}}var c=this.model.edges;for(g=0;g<c.length;g++){var v=c[g];var f=this.getVertexPosition(v.source);var u=this.getVertexPosition(v.target);this._edges[v.id]={points:[{x:f.left+f.width*.5,y:f.top+f.height*.5},{x:u.left+u.width*.5,y:u.top+u.height*.5}]}}e()},getVertexSize:function(t){t=this._vertices&&this._vertices[t.id];return t?{width:t.width,height:t.height}:{width:64,height:64}},getVertexPosition:function(t){t=this._vertices&&this._vertices[t];return t&&t.pos},getEdgeRoute:function(t){t=this._edges&&this._edges[t];return t}};u8.services.factory.ready("GraphModel",function(){u8.Base.Graphs.addLayout("grid",{create:function(e){return new t(e)}})})})();