oneapm_rpm 1.3.1 → 1.3.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTc1NTU2NGU5ZjU4ZjU0MzMwZGE5NGI0ZjM2YWUzZGM1OTRkZDI1Nw==
4
+ YzIyNDBlNmY2Y2JmNDViYmY5OTE3NTQ3Yjc0ZjIwYTRiYzg3OGJkYw==
5
5
  data.tar.gz: !binary |-
6
- ZDk2ZTNhNmUwYTY3NGNlNmRhMWM4YWFkZmRiMzE2ZTgyZjdlMTk1Ng==
6
+ OGE0OGMzODgzMjFjNDUwYjZiMDNmNWQ5YjdlY2Q0M2Q4ZGM3Y2M4YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MTU1YWJlODVmNjJhNmJjOGJmMWVjN2EzMWYwM2I3MmNhYWI1ODJlMzExZmVk
10
- YjJiYzNiZDBmM2JlYzk5NDYyODFkNTY3MmE0MmI4N2Q2OTEyMjlhMjViNDMx
11
- Y2RiOWYxNGEzMjNlY2FlYjM5NDUxZDBiMmIxMDJhZGQ4ZGE3ODI=
9
+ NjcxODMzZDQyYmZmOGM5ZDQ3NjQxZWVlZGI5YmUzYzYyMjc3N2EwYzJhNTNh
10
+ NWUxNDg3YzM4ZWJiYTg3ZmRiOWJkYzc0YzJkNTM0YjQwMzNhY2RkZjRkN2Y3
11
+ MjE3NzBiZjI5MTBmYzgxNjMyYzlhZmFlYTA2ZGFhY2FlOWZiNGU=
12
12
  data.tar.gz: !binary |-
13
- YmZjYTFmZjg2YWQ5OGI3NmU0Y2Q0Y2QyYjQwN2VhNzlhZTdhMWFhOTY4NWJh
14
- YzFjZjQ1NzhkY2E3ZmQ1OTQ2ZTgxMzlmZWY5YTIwN2I3YTA4OWQ0NGFjMDQ1
15
- NGYxYzIzZjY2Y2JmNmIxMjdkYmRhNjJlMmVjNDg4NWI0MGVhNDY=
13
+ M2M0YWUyZGY5NGRjYzZjZWFjNzkxZWYzMDQ3ZGVkYTYxNGMxOGRhMGVmYTVm
14
+ OThlMjAzNjM3ZDQ4YjAxODZiNzdjOWRlYjA0NGNmZGYyYzAxZTJlNzNhNjE3
15
+ YWVlMDdjMDQxODNmY2FiYzVkMjFiZDNmODhhMGJlZDAzYmFmYTQ=
@@ -10,6 +10,8 @@ module OneApm
10
10
 
11
11
  class ThreadProfilerSession
12
12
 
13
+ attr_reader :backtrace_service
14
+
13
15
  def initialize(backtrace_service)
14
16
  @backtrace_service = backtrace_service
15
17
  end
@@ -98,7 +98,7 @@ module OneApm
98
98
  end
99
99
 
100
100
  def get_agent_commands
101
- commands = one_apm_service.get_agent_commands
101
+ commands = one_apm_service.get_agent_commands || []
102
102
  OneApm::Manager.logger.info "Received get_agent_commands = #{commands.inspect}" if commands.any?
103
103
  commands.map {|collector_command| OneApm::Collector::Commands::AgentCommand.new(collector_command)}
104
104
  end
@@ -0,0 +1,32 @@
1
+ # encoding: utf-8
2
+
3
+ LibraryDetection.defer do
4
+ named :rubyprof
5
+
6
+ depends_on do
7
+ defined?(::RubyProf) && defined?(::OneApm::Rack::DeveloperMode) && ::OneApm::Manager.config[:developer_mode]
8
+ end
9
+
10
+ executes do
11
+ ::OneApm::Manager.agent.events.subscribe(:start_transaction) do
12
+ if ::OneApm::Rack::DeveloperMode.profiled?
13
+ begin
14
+ ::RubyProf.start
15
+ rescue => e
16
+ OneApm::Manager.logger.debug e.message
17
+ end
18
+ end
19
+ end
20
+
21
+ ::OneApm::Manager.agent.events.subscribe(:transaction_finished) do
22
+ if ::OneApm::Rack::DeveloperMode.profiled?
23
+ begin
24
+ trace = OneApm::TransactionState.tl_get.current_transaction.transaction_trace
25
+ trace.profile = ::RubyProf.stop
26
+ rescue => e
27
+ OneApm::Manager.logger.debug e.message
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -26,6 +26,7 @@ module OneApm
26
26
  @req = ::Rack::Request.new(env)
27
27
  @start_memory_used = current_memory_used
28
28
  return dup._call(env) if /^\/oneapm/ =~ @req.path_info
29
+ set_profiled
29
30
  status, headers, body = @app.call(env)
30
31
  if status == 200 && headers['Content-Type'] =~ /text\/html/
31
32
  result = inject_profiler(env, status, headers, body)
@@ -34,6 +35,14 @@ module OneApm
34
35
  return [status,headers,body]
35
36
  end
36
37
 
38
+ def self.profiled?
39
+ @profiled
40
+ end
41
+
42
+ def self.profiled=(profiled)
43
+ @profiled = profiled
44
+ end
45
+
37
46
  protected
38
47
 
39
48
  def _call(env)
@@ -55,6 +64,8 @@ module OneApm
55
64
  show_sample_data
56
65
  when /show_sample_sql/
57
66
  show_sample_data
67
+ when /show_sample_profile/
68
+ show_sample_profile
58
69
  when /explain_sql/
59
70
  explain_sql
60
71
  when /^\/oneapm\/?$/
@@ -66,6 +77,18 @@ module OneApm
66
77
 
67
78
  private
68
79
 
80
+ def set_profiled
81
+ DeveloperMode.profiled = params['p'] == 'on'
82
+ end
83
+
84
+ def request_path
85
+ @request_path ||= begin
86
+ path = @req.path.gsub('/', '-')
87
+ path.slice!(0)
88
+ path
89
+ end
90
+ end
91
+
69
92
  def inject_profiler(env, status, headers, body)
70
93
  # mini profiler is meddling with stuff, we can not cache cause we will get incorrect data
71
94
  # Rack::ETag has already inserted some nonesense in the chain
@@ -113,10 +136,9 @@ module OneApm
113
136
  template = read_script_file "#{VIEW_PATH}/oneapm/slide.tmpl"
114
137
  samples = ""
115
138
 
116
- current_transaction = OneApm::TransactionState.tl_get.current_transaction
117
139
  duration = current_duration
118
140
  memory_used = current_memory_used - @start_memory_used
119
- samples = "<a href=\"#\" data-guid=\"#{current_transaction.guid}\" data-uri=\"#{@req.path_info}\" data-duration=\"#{(duration * 1000).round(2)}\" data-memory=\"#{memory_used.round(2)}\"><li>#{(duration * 1000).round(2)} ms</li></a>"
141
+ samples = "<a href=\"#\" data-guid=\"#{current_sample_guid}\" data-uri=\"#{@req.path_info}\" data-duration=\"#{(duration * 1000).round(2)}\" data-memory=\"#{memory_used.round(2)}\"><li>#{(duration * 1000).round(2)} ms</li></a>"
120
142
  template.gsub(/\{samples\}/, samples)
121
143
  end
122
144
 
@@ -125,6 +147,11 @@ module OneApm
125
147
  index = get_samples.find_index{|sample|sample.sample_id == last_sample_id}
126
148
  index.nil? ? get_samples : get_samples[0...index]
127
149
  end
150
+
151
+ def current_sample_guid
152
+ current_transaction = OneApm::TransactionState.tl_get.current_transaction
153
+ current_transaction.guid
154
+ end
128
155
 
129
156
  def last_sample_id
130
157
  Thread.current[:last_sample_id].to_i
@@ -155,7 +182,7 @@ module OneApm
155
182
  regex = /<\/body>/i
156
183
  close_tag = '</body>'
157
184
  else
158
- return fragment
185
+ return fragment
159
186
  end
160
187
 
161
188
  matches = fragment.scan(regex).length
@@ -281,23 +308,24 @@ module OneApm
281
308
  @segment
282
309
  end
283
310
 
284
- def show_sample_data
311
+ def show_sample_profile
285
312
  get_sample
286
-
287
313
  return render(:sample_not_found) unless @sample
314
+ sort_method = params['sort'] || :total_time
315
+ @profile_options = {:min_percent => 0.5, :sort_method => sort_method.to_sym}
316
+ render(:show_sample_profile, false)
317
+ end
288
318
 
319
+ def show_sample_data
320
+ get_sample
321
+ return render(:sample_not_found) unless @sample
289
322
  controller_metric = @sample.transaction_name
290
-
291
323
  @sample_controller_name = controller_metric
292
-
293
324
  @sql_segments = @sample.sql_segments
294
325
  if params['d']
295
326
  @sql_segments.sort!{|a,b| b.duration <=> a.duration }
296
327
  end
297
328
 
298
- sort_method = params['sort'] || :total_time
299
- @profile_options = {:min_percent => 0.5, :sort_method => sort_method.to_sym}
300
-
301
329
  render(:show_sample)
302
330
  end
303
331
 
@@ -284,16 +284,19 @@ module OneApm::DeveloperModeHelper
284
284
 
285
285
  def profile_table(sample, options)
286
286
  out = StringIO.new
287
- printer = RubyProf::GraphHtmlPrinter.new(sample.profile)
288
- printer.print(out, options)
289
- out = out.string[/<body>(.*)<\/body>/im, 0].gsub('<table>', '<table class=profile>')
290
- SORT_REPLACEMENTS.each do |text, param|
291
- replacement = (options[:sort_method] == param) ?
292
- "<th> #{text}&nbsp;&darr;</th>" :
293
- "<th>#{link_to text, "show_sample_summary?id=#{sample.sample_id}&sort=#{param}"}</th>"
294
-
295
- out.gsub!(/<th> +#{text}<\/th>/, replacement)
287
+ sample.profile.eliminate_methods!([/OneApm/]) rescue nil
288
+ if dot?
289
+ printer = ::RubyProf::DotPrinter.new(sample.profile)
290
+ printer.print(out, options)
291
+ "\"#{out.string .gsub('"', '\"').gsub("\n", '')}\""
292
+ else
293
+ printer = ::RubyProf::CallStackPrinter.new(sample.profile)
294
+ printer.print(out, options)
295
+ out.string
296
296
  end
297
- out
297
+ end
298
+
299
+ def dot?
300
+ params['t'] == 'dot'
298
301
  end
299
302
  end
@@ -0,0 +1,2 @@
1
+ (function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var j=typeof require=="function"&&require;if(!h&&j)return j(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}var f=typeof require=="function"&&require;for(var g=0;g<d.length;g++)e(d[g]);return e})({1:[function(a,b,c){var d=self;d.dagreD3=a("./index")},{"./index":2}],2:[function(a,b,c){b.exports={Digraph:a("graphlib").Digraph,Renderer:a("./lib/Renderer"),json:a("graphlib").converter.json,layout:a("dagre").layout,version:a("./lib/version")}},{"./lib/Renderer":3,"./lib/version":4,dagre:11,graphlib:28}],3:[function(a,b,c){function g(){this._layout=d(),this.drawNodes(k),this.drawEdgeLabels(l),this.drawEdgePaths(m),this.positionNodes(n),this.positionEdgeLabels(o),this.positionEdgePaths(p),this.transition(q),this.postLayout(r),this.postRender(s),this.edgeInterpolate("bundle"),this.edgeTension(.95)}function h(a){var b=a.copy();return b.nodes().forEach(function(a){var c=b.node(a);c===undefined&&(c={},b.node(a,c)),"label"in c||(c.label="")}),b.edges().forEach(function(a){var c=b.edge(a);c===undefined&&(c={},b.edge(a,c)),"label"in c||(c.label="")}),b}function i(a,b){var c=a.getBBox();b.width=c.width,b.height=c.height}function j(a,b){var c=b.run(a);return a.eachNode(function(a,b){c.node(a).label=b.label}),a.eachEdge(function(a,b,d,e){c.edge(a).label=e.label}),c}function k(a,b){var c=a.nodes().filter(function(b){return!z(a,b)}),d=b.selectAll("g.node").classed("enter",!1).data(c,function(a){return a});return d.selectAll("*").remove(),d.enter().append("g").style("opacity",0).attr("class","node enter"),d.each(function(b){t(a.node(b),e.select(this),10,10)}),this._transition(d.exit()).style("opacity",0).remove(),d}function l(a,b){var c=b.selectAll("g.edgeLabel").classed("enter",!1).data(a.edges(),function(a){return a});return c.selectAll("*").remove(),c.enter().append("g").style("opacity",0).attr("class","edgeLabel enter"),c.each(function(b){t(a.edge(b),e.select(this),0,0)}),this._transition(c.exit()).style("opacity",0).remove(),c}function n(a,b,c){function d(b){var c=a.node(b);return"translate("+c.x+","+c.y+")"}b.filter(".enter").attr("transform",d),this._transition(b).style("opacity",1).attr("transform",d)}function o(a,b){function c(b){var c=a.edge(b),d=x(c.points);return"translate("+d.x+","+d.y+")"}b.filter(".enter").attr("transform",c),this._transition(b).style("opacity",1).attr("transform",c)}function p(a,b){function f(b){var f=a.edge(b),g=a.node(a.incidentNodes(b)[0]),h=a.node(a.incidentNodes(b)[1]),i=f.points.slice(),j=i.length===0?h:i[0],k=i.length===0?g:i[i.length-1];return i.unshift(y(g,j)),i.push(y(h,k)),e.svg.line().x(function(a){return a.x}).y(function(a){return a.y}).interpolate(c).tension(d)(i)}var c=this._edgeInterpolate,d=this._edgeTension;b.filter(".enter").selectAll("path").attr("d",f),this._transition(b.selectAll("path")).attr("d",f).style("opacity",1)}function q(a){return a}function r(){}function s(a,b){a.isDirected()&&b.select("#arrowhead").empty()&&b.append("svg:defs").append("svg:marker").attr("id","arrowhead").attr("viewBox","0 0 10 10").attr("refX",8).attr("refY",5).attr("markerUnits","strokewidth").attr("markerWidth",8).attr("markerHeight",5).attr("orient","auto").attr("style","fill: #333").append("svg:path").attr("d","M 0 0 L 10 5 L 0 10 z")}function t(a,b,c,d){var e=a.label,f=b.append("rect"),g=b.append("g");e[0]==="<"?(u(e,g),c=d=0):v(e,g,Math.floor(a.labelCols),a.labelCut);var h=b.node().getBBox();g.attr("transform","translate("+ -h.width/2+","+ -h.height/2+")"),f.attr("rx",5).attr("ry",5).attr("x",-(h.width/2+c)).attr("y",-(h.height/2+d)).attr("width",h.width+2*c).attr("height",h.height+2*d)}function u(a,b){var c=b.append("foreignObject").attr("width","100000"),d,e;c.append("xhtml:div").style("float","left").html(function(){return a}).each(function(){d=this.clientWidth,e=this.clientHeight}),c.attr("width",d).attr("height",e)}function v(a,b,c,d){d===undefined&&(d="false"),d=d.toString().toLowerCase()==="true";var e=b.append("text").attr("text-anchor","left");a=a.replace(/\\n/g,"\n");var f=c?w(a,c,d):a;f=f.split("\n");for(var g=0;g<f.length;g++)e.append("tspan").attr("dy","1em").attr("x","1").text(f[g])}function w(a,b,c,d){d=d||"\n",b=b||75,c=c||!1;if(!a)return a;var e=".{1,"+b+"}(\\s|$)"+(c?"|.{"+b+"}|.+$":"|\\S+?(\\s|$)");return a.match(RegExp(e,"g")).join(d)}function x(a){var b=a.length/2;if(a.length%2)return a[Math.floor(b)];var c=a[b-1],d=a[b];return{x:(c.x+d.x)/2,y:(c.y+d.y)/2}}function y(a,b){var c=a.x,d=a.y,e=b.x-c,f=b.y-d,g=a.width/2,h=a.height/2,i,j;return Math.abs(f)*g>Math.abs(e)*h?(f<0&&(h=-h),i=f===0?0:h*e/f,j=h):(e<0&&(g=-g),i=g,j=e===0?0:g*f/e),{x:c+i,y:d+j}}function z(a,b){return"children"in a&&a.children(b).length}function A(a,b){return a.bind?a.bind(b):function(){return a.apply(b,arguments)}}var d=a("dagre").layout,e;try{e=a("d3")}catch(f){e=window.d3}b.exports=g,g.prototype.layout=function(a){return arguments.length?(this._layout=a,this):this._layout},g.prototype.drawNodes=function(a){return arguments.length?(this._drawNodes=A(a,this),this):this._drawNodes},g.prototype.drawEdgeLabels=function(a){return arguments.length?(this._drawEdgeLabels=A(a,this),this):this._drawEdgeLabels},g.prototype.drawEdgePaths=function(a){return arguments.length?(this._drawEdgePaths=A(a,this),this):this._drawEdgePaths},g.prototype.positionNodes=function(a){return arguments.length?(this._positionNodes=A(a,this),this):this._positionNodes},g.prototype.positionEdgeLabels=function(a){return arguments.length?(this._positionEdgeLabels=A(a,this),this):this._positionEdgeLabels},g.prototype.positionEdgePaths=function(a){return arguments.length?(this._positionEdgePaths=A(a,this),this):this._positionEdgePaths},g.prototype.transition=function(a){return arguments.length?(this._transition=A(a,this),this):this._transition},g.prototype.postLayout=function(a){return arguments.length?(this._postLayout=A(a,this),this):this._postLayout},g.prototype.postRender=function(a){return arguments.length?(this._postRender=A(a,this),this):this._postRender},g.prototype.edgeInterpolate=function(a){return arguments.length?(this._edgeInterpolate=a,this):this._edgeInterpolate},g.prototype.edgeTension=function(a){return arguments.length?(this._edgeTension=a,this):this._edgeTension},g.prototype.run=function(a,b){a=h(a),b.selectAll("g.edgePaths, g.edgeLabels, g.nodes").data(["edgePaths","edgeLabels","nodes"]).enter().append("g").attr("class",function(a){return a});var c=this._drawNodes(a,b.select("g.nodes")),d=this._drawEdgeLabels(a,b.select("g.edgeLabels"));c.each(function(b){i(this,a.node(b))}),d.each(function(b){i(this,a.edge(b))});var e=j(a,this._layout);this._postLayout(e,b);var f=this._drawEdgePaths(a,b.select("g.edgePaths"));return this._positionNodes(e,c),this._positionEdgeLabels(e,d),this._positionEdgePaths(e,f),this._postRender(e,b),e};var m=function(a,b){var c=b.selectAll("g.edgePath").classed("enter",!1).data(a.edges(),function(a){return a});return c.enter().append("g").attr("class","edgePath enter").append("path").style("opacity",0).attr("marker-end","url(#arrowhead)"),this._transition(c.exit()).style("opacity",0).remove(),c}},{d3:10,dagre:11}],4:[function(a,b,c){b.exports="0.1.5"},{}],5:[function(a,b,c){c.Set=a("./lib/Set"),c.PriorityQueue=a("./lib/PriorityQueue"),c.version=a("./lib/version")},{"./lib/PriorityQueue":6,"./lib/Set":7,"./lib/version":9}],6:[function(a,b,c){function d(){this._arr=[],this._keyIndices={}}b.exports=d,d.prototype.size=function(){return this._arr.length},d.prototype.keys=function(){return this._arr.map(function(a){return a.key})},d.prototype.has=function(a){return a in this._keyIndices},d.prototype.priority=function(a){var b=this._keyIndices[a];if(b!==undefined)return this._arr[b].priority},d.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},d.prototype.add=function(a,b){var c=this._keyIndices;if(a in c)return!1;var d=this._arr,e=d.length;return c[a]=e,d.push({key:a,priority:b}),this._decrease(e),!0},d.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var a=this._arr.pop();return delete this._keyIndices[a.key],this._heapify(0),a.key},d.prototype.decrease=function(a,b){var c=this._keyIndices[a];if(b>this._arr[c].priority)throw new Error("New priority is greater than current priority. Key: "+a+" Old: "+this._arr[c].priority+" New: "+b);this._arr[c].priority=b,this._decrease(c)},d.prototype._heapify=function(a){var b=this._arr,c=2*a,d=c+1,e=a;c<b.length&&(e=b[c].priority<b[e].priority?c:e,d<b.length&&(e=b[d].priority<b[e].priority?d:e),e!==a&&(this._swap(a,e),this._heapify(e)))},d.prototype._decrease=function(a){var b=this._arr,c=b[a].priority,d;while(a!==0){d=a>>1;if(b[d].priority<c)break;this._swap(a,d),a=d}},d.prototype._swap=function(a,b){var c=this._arr,d=this._keyIndices,e=c[a],f=c[b];c[a]=f,c[b]=e,d[f.key]=a,d[e.key]=b}},{}],7:[function(a,b,c){function e(a){this._size=0,this._keys={};if(a)for(var b=0,c=a.length;b<c;++b)this.add(a[b])}function f(a){var b=Object.keys(a),c=b.length,d=new Array(c),e;for(e=0;e<c;++e)d[e]=a[b[e]];return d}var d=a("./util");b.exports=e,e.intersect=function(a){if(a.length===0)return new e;var b=new e(d.isArray(a[0])?a[0]:a[0].keys());for(var c=1,f=a.length;c<f;++c){var g=b.keys(),h=d.isArray(a[c])?new e(a[c]):a[c];for(var i=0,j=g.length;i<j;++i){var k=g[i];h.has(k)||b.remove(k)}}return b},e.union=function(a){var b=d.reduce(a,function(a,b){return a+(b.size?b.size():b.length)},0),c=new Array(b),f=0;for(var g=0,h=a.length;g<h;++g){var i=a[g],j=d.isArray(i)?i:i.keys();for(var k=0,l=j.length;k<l;++k)c[f++]=j[k]}return new e(c)},e.prototype.size=function(){return this._size},e.prototype.keys=function(){return f(this._keys)},e.prototype.has=function(a){return a in this._keys},e.prototype.add=function(a){return a in this._keys?!1:(this._keys[a]=a,++this._size,!0)},e.prototype.remove=function(a){return a in this._keys?(delete this._keys[a],--this._size,!0):!1}},{"./util":8}],8:[function(a,b,c){Array.isArray?c.isArray=Array.isArray:c.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"},"function"!=typeof Array.prototype.reduce?c.reduce=function(a,b,c){"use strict";if(null===a||"undefined"==typeof a)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var d,e,f=a.length>>>0,g=!1;1<arguments.length&&(e=c,g=!0);for(d=0;f>d;++d)a.hasOwnProperty(d)&&(g?e=b(e,a[d],d,a):(e=a[d],g=!0));if(!g)throw new TypeError("Reduce of empty array with no initial value");return e}:c.reduce=function(a,b,c){return a.reduce(b,c)}},{}],9:[function(a,b,c){b.exports="1.1.3"},{}],10:[function(a,b,c){a("./d3"),b.exports=d3,function(){delete this.d3}()},{}],11:[function(a,b,c){c.Digraph=a("graphlib").Digraph,c.Graph=a("graphlib").Graph,c.layout=a("./lib/layout"),c.version=a("./lib/version")},{"./lib/layout":12,"./lib/version":27,graphlib:28}],12:[function(a,b,c){var d=a("./util"),e=a("./rank"),f=a("./order"),g=a("graphlib").CGraph,h=a("graphlib").CDigraph;b.exports=function(){function j(a){var c=new h;a.eachNode(function(a,b){b===undefined&&(b={}),c.addNode(a,{width:b.width,height:b.height}),b.hasOwnProperty("rank")&&(c.node(a).prefRank=b.rank)}),a.parent&&a.nodes().forEach(function(b){c.parent(b,a.parent(b))}),a.eachEdge(function(a,b,d,e){e===undefined&&(e={});var f={e:a,minLen:e.minLen||1,width:e.width||0,height:e.height||0,points:[]};c.addEdge(null,b,d,f)});var d=a.graph()||{};return c.graph({rankDir:d.rankDir||b.rankDir,orderRestarts:d.orderRestarts}),c}function k(a){var g=i.rankSep(),h;try{return h=d.time("initLayoutGraph",j)(a),h.order()===0?h:(h.eachEdge(function(a,b,c,d){d.minLen*=2}),i.rankSep(g/2),d.time("rank.run",e.run)(h,b.rankSimplex),d.time("normalize",l)(h),d.time("order",f)(h,b.orderMaxSweeps),d.time("position",c.run)(h),d.time("undoNormalize",m)(h),d.time("fixupEdgePoints",n)(h),d.time("rank.restoreEdges",e.restoreEdges)(h),d.time("createFinalGraph",o)(h,a.isDirected()))}finally{i.rankSep(g)}}function l(a){var b=0;a.eachEdge(function(c,d,e,f){var g=a.node(d).rank,h=a.node(e).rank;if(g+1<h){for(var i=d,j=g+1,k=0;j<h;++j,++k){var l="_D"+ ++b,m={width:f.width,height:f.height,edge:{id:c,source:d,target:e,attrs:f},rank:j,dummy:!0};k===0?m.index=0:j+1===h&&(m.index=1),a.addNode(l,m),a.addEdge(null,i,l,{}),i=l}a.addEdge(null,i,e,{}),a.delEdge(c)}})}function m(a){a.eachNode(function(b,c){if(c.dummy){if("index"in c){var d=c.edge;a.hasEdge(d.id)||a.addEdge(d.id,d.source,d.target,d.attrs);var e=a.edge(d.id).points;e[c.index]={x:c.x,y:c.y,ul:c.ul,ur:c.ur,dl:c.dl,dr:c.dr}}a.delNode(b)}})}function n(a){a.eachEdge(function(a,b,c,d){d.reversed&&d.points.reverse()})}function o(a,b){var c=b?new h:new g;c.graph(a.graph()),a.eachNode(function(a,b){c.addNode(a,b)}),a.eachNode(function(b){c.parent(b,a.parent(b))}),a.eachEdge(function(a,b,d,e){c.addEdge(e.e,b,d,e)});var d=0,e=0;return a.eachNode(function(b,c){a.children(b).length||(d=Math.max(d,c.x+c.width/2),e=Math.max(e,c.y+c.height/2))}),a.eachEdge(function(a,b,c,f){var g=Math.max.apply(Math,f.points.map(function(a){return a.x})),h=Math.max.apply(Math,f.points.map(function(a){return a.y}));d=Math.max(d,g+f.width/2),e=Math.max(e,h+f.height/2)}),c.graph().width=d,c.graph().height=e,c}function p(a){return function(){return arguments.length?(a.apply(null,arguments),i):a()}}var b={debugLevel:0,orderMaxSweeps:f.DEFAULT_MAX_SWEEPS,rankSimplex:!1,rankDir:"TB"},c=a("./position")(),i={};return i.orderIters=d.propertyAccessor(i,b,"orderMaxSweeps"),i.rankSimplex=d.propertyAccessor(i,b,"rankSimplex"),i.nodeSep=p(c.nodeSep),i.edgeSep=p(c.edgeSep),i.universalSep=p(c.universalSep),i.rankSep=p(c.rankSep),i.rankDir=d.propertyAccessor(i,b,"rankDir"),i.debugAlignment=p(c.debugAlignment),i.debugLevel=d.propertyAccessor(i,b,"debugLevel",function(a){d.log.level=a,c.debugLevel(a)}),i.run=d.time("Total layout",k),i._normalize=l,i}},{"./order":13,"./position":18,"./rank":19,"./util":26,graphlib:28}],13:[function(a,b,c){function k(a,b){function o(){a.eachNode(function(a,b){m[a]=b.order})}arguments.length<2&&(b=j);var c=a.graph().orderRestarts||0,h=f(a);h.forEach(function(b){b=b.filterNodes(function(b){return!a.children(b).length})});var i=0,k,l=Number.MAX_VALUE,m={};for(var p=0;p<Number(c)+1&&l!==0;++p){k=Number.MAX_VALUE,g(a,c>0),d.log(2,"Order phase start cross count: "+a.graph().orderInitCC);var q,r,s;for(q=0,r=0;r<4&&q<b&&k>0;++q,++r,++i)n(a,h,q),s=e(a),s<k&&(r=0,k=s,s<l&&(o(),l=s)),d.log(3,"Order phase start "+p+" iter "+q+" cross count: "+s)}Object.keys(m).forEach(function(b){if(!a.children||!a.children(b).length)a.node(b).order=m[b]}),a.graph().orderCC=l,d.log(2,"Order iterations: "+i),d.log(2,"Order phase best cross count: "+a.graph().orderCC)}function l(a,b){var c={};return b.forEach(function(b){c[b]=a.inEdges(b).map(function(b){return a.node(a.source(b)).order})}),c}function m(a,b){var c={};return b.forEach(function(b){c[b]=a.outEdges(b).map(function(b){return a.node(a.target(b)).order})}),c}function n(a,b,c){c%2===0?o(a,b,c):p(a,b,c)}function o(a,b){var c;for(i=1;i<b.length;++i)c=h(b[i],c,l(a,b[i].nodes()))}function p(a,b){var c;for(i=b.length-2;i>=0;--i)h(b[i],c,m(a,b[i].nodes()))}var d=a("./util"),e=a("./order/crossCount"),f=a("./order/initLayerGraphs"),g=a("./order/initOrder"),h=a("./order/sortLayer");b.exports=k;var j=24;k.DEFAULT_MAX_SWEEPS=j},{"./order/crossCount":14,"./order/initLayerGraphs":15,"./order/initOrder":16,"./order/sortLayer":17,"./util":26}],14:[function(a,b,c){function e(a){var b=0,c=d.ordering(a);for(var e=1;e<c.length;++e)b+=f(a,c[e-1],c[e]);return b}function f(a,b,c){var d=[];b.forEach(function(b){var c=[];a.outEdges(b).forEach(function(b){c.push(a.node(a.target(b)).order)}),c.sort(function(a,b){return a-b}),d=d.concat(c)});var e=1;while(e<c.length)e<<=1;var f=2*e-1;e-=1;var g=[];for(var h=0;h<f;++h)g[h]=0;var i=0;return d.forEach(function(a){var b=a+e;++g[b];while(b>0)b%2&&(i+=g[b+1]),b=b-1>>1,++g[b]}),i}var d=a("../util");b.exports=e},{"../util":26}],15:[function(a,b,c){function f(a){function c(d){if(d===null){a.children(d).forEach(function(a){c(a)});return}var f=a.node(d);f.minRank="rank"in f?f.rank:Number.MAX_VALUE,f.maxRank="rank"in f?f.rank:Number.MIN_VALUE;var h=new e;return a.children(d).forEach(function(b){var d=c(b);h=e.union([h,d]),f.minRank=Math.min(f.minRank,a.node(b).minRank),f.maxRank=Math.max(f.maxRank,a.node(b).maxRank)}),"rank"in f&&h.add(f.rank),h.keys().forEach(function(a){a in b||(b[a]=[]),b[a].push(d)}),h}var b=[];c(null);var f=[];return b.forEach(function(b,c){f[c]=a.filterNodes(d(b))}),f}var d=a("graphlib").filter.nodesFromList,e=a("cp-data").Set;b.exports=f},{"cp-data":5,graphlib:28}],16:[function(a,b,c){function f(a,b){var c=[];a.eachNode(function(b,d){var e=c[d.rank];if(a.children&&a.children(b).length>0)return;e||(e=c[d.rank]=[]),e.push(b)}),c.forEach(function(c){b&&e.shuffle(c),c.forEach(function(b,c){a.node(b).order=c})});var f=d(a);a.graph().orderInitCC=f,a.graph().orderCC=Number.MAX_VALUE}var d=a("./crossCount"),e=a("../util");b.exports=f},{"../util":26,"./crossCount":14}],17:[function(a,b,c){function e(a,b,c){var e=[],f={};a.eachNode(function(a,b){e[b.order]=a;var g=c[a];g.length&&(f[a]=d.sum(g)/g.length)});var g=a.nodes().filter(function(a){return f[a]!==undefined});g.sort(function(b,c){return f[b]-f[c]||a.node(b).order-a.node(c).order});for(var h=0,i=0,j=g.length;i<j;++h)f[e[h]]!==undefined&&(a.node(g[i++]).order=h)}var d=a("../util");b.exports=e},{"../util":26}],18:[function(a,b,c){var d=a("./util");b.exports=function(){function c(b){b=b.filterNodes(d.filterNonSubgraphs(b));var c=d.ordering(b),e=f(b,c),i={};["u","d"].forEach(function(d){d==="d"&&c.reverse(),["l","r"].forEach(function(f){f==="r"&&m(c);var j=d+f,k=g(b,c,e,d==="u"?"predecessors":"successors");i[j]=h(b,c,k.pos,k.root,k.align),a.debugLevel>=3&&t(d+f,b,c,i[j]),f==="r"&&l(i[j]),f==="r"&&m(c)}),d==="d"&&c.reverse()}),k(b,c,i),b.eachNode(function(a){var c=[];for(var d in i){var e=i[d][a];r(d,b,a,e),c.push(e)}c.sort(function(a,b){return a-b}),q(b,a,(c[1]+c[2])/2)});var j=0,p=b.graph().rankDir==="BT"||b.graph().rankDir==="RL";c.forEach(function(c){var e=d.max(c.map(function(a){return o(b,a)}));j+=e/2,c.forEach(function(a){s(b,a,p?-j:j)}),j+=e/2+a.rankSep});var u=d.min(b.nodes().map(function(a){return q(b,a)-n(b,a)/2})),v=d.min(b.nodes().map(function(a){return s(b,a)-o(b,a)/2}));b.eachNode(function(a){q(b,a,q(b,a)-u),s(b,a,s(b,a)-v)})}function e(a,b){return a<b?a.toString().length+":"+a+"-"+b:b.toString().length+":"+b+"-"+a}function f(a,b){function k(a){var b=d[a];if(b<h||b>j)c[e(g[i],a)]=!0}var c={},d={},f,g,h,i,j;if(b.length<=2)return c;b[1].forEach(function(a,b){d[a]=b});for(var l=1;l<b.length-1;++l){f=b[l],g=b[l+1],h=0,i=0;for(var m=0;m<g.length;++m){var n=g[m];d[n]=m,j=undefined;if(a.node(n).dummy){var o=a.predecessors(n)[0];o!==undefined&&a.node(o).dummy&&(j=d[o])}j===undefined&&m===g.length-1&&(j=f.length-1);if(j!==undefined){for(;i<=m;++i)a.predecessors(g[i]).forEach(k);h=j}}}return c}function g(a,b,c,d){var f={},g={},h={};return b.forEach(function(a){a.forEach(function(a,b){g[a]=a,h[a]=a,f[a]=b})}),b.forEach(function(b){var i=-1;b.forEach(function(b){var j=a[d](b),k;j.length>0&&(j.sort(function(a,b){return f[a]-f[b]}),k=(j.length-1)/2,j.slice(Math.floor(k),Math.ceil(k)+1).forEach(function(a){h[b]===b&&!c[e(a,b)]&&i<f[a]&&(h[a]=b,h[b]=g[b]=g[a],i=f[a])}))})}),{pos:f,root:g,align:h}}function h(a,b,c,e,f){function l(a,b,c){b in h[a]?h[a][b]=Math.min(h[a][b],c):h[a][b]=c}function m(b){if(!(b in k)){k[b]=0;var d=b;do{if(c[d]>0){var h=e[j[d]];m(h),g[b]===b&&(g[b]=g[h]);var i=p(a,j[d])+p(a,d);g[b]!==g[h]?l(g[h],g[b],k[b]-k[h]-i):k[b]=Math.max(k[b],k[h]+i)}d=f[d]}while(d!==b)}}var g={},h={},i={},j={},k={};return b.forEach(function(a){a.forEach(function(b,c){g[b]=b,h[b]={},c>0&&(j[b]=a[c-1])})}),d.values(e).forEach(function(a){m(a)}),b.forEach(function(a){a.forEach(function(a){k[a]=k[e[a]];if(a===e[a]&&a===g[a]){var b=0;a in h&&Object.keys(h[a]).length>0&&(b=d.min(Object.keys(h[a]).map(function(b){return h[a][b]+(b in i?i[b]:0)}))),i[a]=b}})}),b.forEach(function(a){a.forEach(function(a){k[a]+=i[g[e[a]]]||0})}),k}function i(a,b,c){return d.min(b.map(function(a){var b=a[0];return c[b]}))}function j(a,b,c){return d.max(b.map(function(a){var b=a[a.length-1];return c[b]}))}function k(a,b,c){function h(a){c[l][a]+=g[l]}var d={},e={},f,g={},k=Number.POSITIVE_INFINITY;for(var l in c){var m=c[l];d[l]=i(a,b,m),e[l]=j(a,b,m);var n=e[l]-d[l];n<k&&(k=n,f=l)}["u","d"].forEach(function(a){["l","r"].forEach(function(b){var c=a+b;g[c]=b==="l"?d[f]-d[c]:e[f]-e[c]})});for(l in c)a.eachNode(h)}function l(a){for(var b in a)a[b]=-a[b]}function m(a){a.forEach(function(a){a.reverse()})}function n(a,b){switch(a.graph().rankDir){case"LR":return a.node(b).height;case"RL":return a.node(b).height;default:return a.node(b).width}}function o(a,b){switch(a.graph().rankDir){case"LR":return a.node(b).width;case"RL":return a.node(b).width;default:return a.node(b).height}}function p(b,c){if(a.universalSep!==null)return a.universalSep;var d=n(b,c),e=b.node(c).dummy?a.edgeSep:a.nodeSep;return(d+e)/2}function q(a,b,c){if(a.graph().rankDir==="LR"||a.graph().rankDir==="RL"){if(arguments.length<3)return a.node(b).y;a.node(b).y=c}else{if(arguments.length<3)return a.node(b).x;a.node(b).x=c}}function r(a,b,c,d){if(b.graph().rankDir==="LR"||b.graph().rankDir==="RL"){if(arguments.length<3)return b.node(c)[a];b.node(c)[a]=d}else{if(arguments.length<3)return b.node(c)[a];b.node(c)[a]=d}}function s(a,b,c){if(a.graph().rankDir==="LR"||a.graph().rankDir==="RL"){if(arguments.length<3)return a.node(b).x;a.node(b).x=c}else{if(arguments.length<3)return a.node(b).y;a.node(b).y=c}}function t(a,b,c,d){c.forEach(function(c,e){var f,g;c.forEach(function(c){var h=d[c];if(f){var i=p(b,f)+p(b,c);h-g<i&&console.log("Position phase: sep violation. Align: "+a+". Layer: "+e+". "+"U: "+f+" V: "+c+". Actual sep: "+(h-g)+" Expected sep: "+i)}f=c,g=h})})}var a={nodeSep:50,edgeSep:10,universalSep:null,rankSep:30},b={};return b.nodeSep=d.propertyAccessor(b,a,"nodeSep"),b.edgeSep=d.propertyAccessor(b,a,"edgeSep"),b.universalSep=d.propertyAccessor(b,a,"universalSep"),b.rankSep=d.propertyAccessor(b,a,"rankSep"),b.debugLevel=d.propertyAccessor(b,a,"debugLevel"),b.run=c,b}},{"./util":26}],19:[function(a,b,c){function l(a,b){n(a),d.time("constraints.apply",h.apply)(a),o(a),d.time("acyclic",e)(a);var c=a.filterNodes(d.filterNonSubgraphs(a));f(c),j(c).forEach(function(a){var d=c.filterNodes(k.nodesFromList(a));r(d,b)}),d.time("constraints.relax",h.relax(a)),d.time("reorientEdges",q)(a)}function m(a){e.undo(a)}function n(a){a.eachEdge(function(b,c,d,e){if(c===d){var f=p(a,b,c,d,e,0,!1),g=p(a,b,c,d,e,1,!0),h=p(a,b,c,d,e,2,!1);a.addEdge(null,f,c,{minLen:1,selfLoop:!0}),a.addEdge(null,f,g,{minLen:1,selfLoop:!0}),a.addEdge(null,c,h,{minLen:1,selfLoop:!0}),a.addEdge(null,g,h,{minLen:1,selfLoop:!0}),a.delEdge(b)}})}function o(a){a.eachEdge(function(b,c,d,e){if(c===d){var f=e.originalEdge,g=p(a,f.e,f.u,f.v,f.value,0,!0);a.addEdge(null,c,g,{minLen:1}),a.addEdge(null,g,d,{minLen:1}),a.delEdge(b)}})}function p(a,b,c,d,e,f,g){return a.addNode(null,{width:g?e.width:0,height:g?e.height:0,edge:{id:b,source:c,target:d,attrs:e},dummy:!0,index:f})}function q(a){a.eachEdge(function(b,c,d,e){a.node(c).rank>a.node(d).rank&&(a.delEdge(b),e.reversed=!0,a.addEdge(b,d,c,e))})}function r(a,b){var c=g(a);b&&(d.log(1,"Using network simplex for ranking"),i(a,c)),s(a)}function s(a){var b=d.min(a.nodes().map(function(b){return a.node(b).rank}));a.eachNode(function(a,c){c.rank-=b})}var d=a("./util"),e=a("./rank/acyclic"),f=a("./rank/initRank"),g=a("./rank/feasibleTree"),h=a("./rank/constraints"),i=a("./rank/simplex"),j=a("graphlib").alg.components,k=a("graphlib").filter;c.run=l,c.restoreEdges=m},{"./rank/acyclic":20,"./rank/constraints":21,"./rank/feasibleTree":22,"./rank/initRank":23,"./rank/simplex":25,"./util":26,graphlib:28}],20:[function(a,b,c){function e(a){function f(d){if(d in c)return;c[d]=b[d]=!0,a.outEdges(d).forEach(function(c){var h=a.target(c),i;d===h?console.error('Warning: found self loop "'+c+'" for node "'+d+'"'):h in b?(i=a.edge(c),a.delEdge(c),i.reversed=!0,++e,a.addEdge(c,h,d,i)):f(h)}),delete b[d]}var b={},c={},e=0;return a.eachNode(function(a){f(a)}),d.log(2,"Acyclic Phase: reversed "+e+" edge(s)"),e}function f(a){a.eachEdge(function(b,c,d,e){e.reversed&&(delete e.reversed,a.delEdge(b),a.addEdge(b,d,c,e))})}var d=a("../util");b.exports=e,b.exports.undo=f},{"../util":26}],21:[function(a,b,c){function d(a){return a!=="min"&&a!=="max"&&a.indexOf("same_")!==0?(console.error("Unsupported rank type: "+a),!1):!0}function e(a,b,c,d){a.inEdges(b).forEach(function(b){var e=a.edge(b),f;e.originalEdge?f=e:f={originalEdge:{e:b,u:a.source(b),v:a.target(b),value:e},minLen:a.edge(b).minLen},e.selfLoop&&(d=!1),d?(a.addEdge(null,c,a.source(b),f),f.reversed=!0):a.addEdge(null,a.source(b),c,f)})}function f(a,b,c,d){a.outEdges(b).forEach(function(b){var e=a.edge(b),f;e.originalEdge?f=e:f={originalEdge:{e:b,u:a.source(b),v:a.target(b),value:e},minLen:a.edge(b).minLen},e.selfLoop&&(d=!1),d?(a.addEdge(null,a.target(b),c,f),f.reversed=!0):a.addEdge(null,c,a.target(b),f)})}function g(a,b,c){c!==undefined&&a.children(b).forEach(function(b){b!==c&&!a.outEdges(c,b).length&&!a.node(b).dummy&&a.addEdge(null,c,b,{minLen:0})})}function h(a,b,c){c!==undefined&&a.children(b).forEach(function(b){b!==c&&!a.outEdges(b,c).length&&!a.node(b).dummy&&a.addEdge(null,b,c,{minLen:0})})}c.apply=function(a){function b(c){var i={};a.children(c).forEach(function(g){if(a.children(g).length){b(g);return}var h=a.node(g),j=h.prefRank;if(j!==undefined){if(!d(j))return;j in i?i.prefRank.push(g):i.prefRank=[g];var k=i[j];k===undefined&&(k=i[j]=a.addNode(null,{originalNodes:[]}),a.parent(k,c)),e(a,g,k,j==="min"),f(a,g,k,j==="max"),a.node(k).originalNodes.push({u:g,value:h,parent:c}),a.delNode(g)}}),g(a,c,i.min),h(a,c,i.max)}b(null)},c.relax=function(a){var b=[];a.eachEdge(function(a,c,d,e){var f=e.originalEdge;f&&b.push(f)}),a.eachNode(function(b,c){var d=c.originalNodes;d&&(d.forEach(function(b){b.value.rank=c.rank,a.addNode(b.u,b.value),a.parent(b.u,b.parent)}),a.delNode(b))}),b.forEach(function(b){a.addEdge(b.e,b.u,b.v,b.value)})}},{}],22:[function(a,b,c){function g(a){function g(d){var e=!0;return a.predecessors(d).forEach(function(f){b.has(f)&&!h(a,f,d)&&(b.has(d)&&(c.addNode(d,{}),b.remove(d),c.graph({root:d})),c.addNode(f,{}),c.addEdge(null,f,d,{reversed:!0}),b.remove(f),g(f),e=!1)}),a.successors(d).forEach(function(f){b.has(f)&&!h(a,d,f)&&(b.has(d)&&(c.addNode(d,{}),b.remove(d),c.graph({root:d})),c.addNode(f,{}),c.addEdge(null,d,f,{}),b.remove(f),g(f),e=!1)}),e}function i(){var d=Number.MAX_VALUE;b.keys().forEach(function(c){a.predecessors(c).forEach(function(e){if(!b.has(e)){var f=h(a,e,c);Math.abs(f)<Math.abs(d)&&(d=-f)}}),a.successors(c).forEach(function(e){if(!b.has(e)){var f=h(a,c,e);Math.abs(f)<Math.abs(d)&&(d=f)}})}),c.eachNode(function(b){a.node(b).rank-=d})}var b=new d(a.nodes()),c=new e;if(b.size()===1){var f=a.nodes()[0];return c.addNode(f,{}),c.graph({root:f}),c}while(b.size()){var j=c.order()?c.nodes():b.keys();for(var k=0,l=j.length;k<l&&g(j[k]);++k);b.size()&&i()}return c}function h(a,b,c){var d=a.node(c).rank-a.node(b).rank,e=f.max(a.outEdges(b,c).map(function(b){return a.edge(b).minLen}));return d-e}var d=a("cp-data").Set,e=a("graphlib").Digraph,f=a("../util");b.exports=g},{"../util":26,"cp-data":5,graphlib:28}],23:[function(a,b,c){function f(a){var b=e(a);b.forEach(function(b){var c=a.inEdges(b);if(c.length===0){a.node(b).rank=0;return}var e=c.map(function(b){return a.node(a.source(b)).rank+a.edge(b).minLen});a.node(b).rank=d.max(e)})}var d=a("../util"),e=a("graphlib").alg.topsort;b.exports=f},{"../util":26,graphlib:28}],24:[function(a,b,c){function d(a,b,c,d){return Math.abs(a.node(b).rank-a.node(c).rank)-d}b.exports={slack:d}},{}],25:[function(a,b,c){function f(a,b){g(a,b);for(;;){var c=k(b);if(c===null)break;var d=l(a,b,c);m(a,b,c,d)}}function g(a,b){function c(d){var e=b.successors(d);for(var f in e){var g=e[f];c(g)}d!==b.graph().root&&i(a,b,d)}h(b),b.eachEdge(function(a,b,c,d){d.cutValue=0}),c(b.graph().root)}function h(a){function c(d){var e=a.successors(d),f=b;for(var g in e){var h=e[g];c(h),f=Math.min(f,a.node(h).low)}a.node(d).low=f,a.node(d).lim=b++}var b=0;c(a.graph().root)}function i(a,b,c){var d=b.inEdges(c)[0],e=[],f=b.outEdges(c);for(var g in f)e.push(b.target(f[g]));var h=0,i=0,k=0,l=0,m=0,n=a.outEdges(c),o;for(var p in n){var q=a.target(n[p]);for(o in e)j(b,q,e[o])&&i++;j(b,q,c)||l++}var r=a.inEdges(c);for(var s in r){var t=a.source(r[s]);for(o in e)j(b,t,e[o])&&k++;j(b,t,c)||m++}var u=0;for(o in e){var v=b.edge(f[o]).cutValue;b.edge(f[o]).reversed?u-=v:u+=v}b.edge(d).reversed?h-=u-i+k-l+m:h+=u-i+k-l+m,b.edge(d).cutValue=h}function j(a,b,c){return a.node(c).low<=a.node(b).lim&&a.node(b).lim<=a.node(c).lim}function k(a){var b=a.edges();for(var c in b){var d=b[c],e=a.edge(d);if(e.cutValue<0)return d}return null}function l(a,b,c){var d=b.source(c),f=b.target(c),g=b.node(f).lim<b.node(d).lim?f:d,h=!b.edge(c).reversed,i=Number.POSITIVE_INFINITY,k;h?a.eachEdge(function(d,f,h,l){if(d!==c&&j(b,f,g)&&!j(b,h,g)){var m=e.slack(a,f,h,l.minLen);m<i&&(i=m,k=d)}}):a.eachEdge(function(d,f,h,l){if(d!==c&&!j(b,f,g)&&j(b,h,g)){var m=e.slack(a,f,h,l.minLen);m<i&&(i=m,k=d)}});if(k===undefined){var l=[],m=[];throw a.eachNode(function(a){j(b,a,g)?m.push(a):l.push(a)}),new Error("No edge found from outside of tree to inside")}return k}function m(a,b,c,d){function h(a){var c=b.inEdges(a);for(var d in c){var e=c[d],f=b.source(e),g=b.edge(e);h(f),b.delEdge(e),g.reversed=!g.reversed,b.addEdge(e,a,f,g)}}b.delEdge(c);var e=a.source(d),f=a.target(d);h(f);var i=e,j=b.inEdges(i);while(j.length>0)i=b.source(j[0]),j=b.inEdges(i);b.graph().root=i,b.addEdge(null,e,f,{cutValue:0}),g(a,b),n(a,b)}function n(a,b){function c(d){var e=b.successors(d);e.forEach(function(b){var e=o(a,d,b);a.node(b).rank=a.node(d).rank+e,c(b)})}c(b.graph().root)}function o(a,b,c){var e=a.outEdges(b,c);if(e.length>0)return d.max(e.map(function(b){return a.edge(b).minLen}));var f=a.inEdges(b,c);if(f.length>0)return-d.max(f.map(function(b){return a.edge(b).minLen}))}var d=a("../util"),e=a("./rankUtil");b.exports=f},{"../util":26,"./rankUtil":24}],26:[function(a,b,c){function d(a,b){return function(){var c=(new Date).getTime();try{return b.apply(null,arguments)}finally{e(1,a+" time: "+((new Date).getTime()-c)+"ms")}}}function e(a){e.level>=a&&console.log.apply(console,Array.prototype.slice.call(arguments,1))}c.min=function(a){return Math.min.apply(Math,a)},c.max=function(a){return Math.max.apply(Math,a)},c.all=function(a,b){for(var c=0;c<a.length;++c)if(!b(a[c]))return!1;return!0},c.sum=function(a){return a.reduce(function(a,b){return a+b},0)},c.values=function(a){return Object.keys(a).map(function(b){return a[b]})},c.shuffle=function(a){for(i=a.length-1;i>0;--i){var b=Math.floor(Math.random()*(i+1)),c=a[b];a[b]=a[i],a[i]=c}},c.propertyAccessor=function(a,b,c,d){return function(e){return arguments.length?(b[c]=e,d&&d(e),a):b[c]}},c.ordering=function(a){var b=[];return a.eachNode(function(a,c){var d=b[c.rank]||(b[c.rank]=[]);d[c.order]=a}),b},c.filterNonSubgraphs=function(a){return function(b){return a.children(b).length===0}},d.enabled=!1,c.time=d,e.level=0,c.log=e},{}],27:[function(a,b,c){b.exports="0.4.5"},{}],28:[function(a,b,c){c.Graph=a("./lib/Graph"),c.Digraph=a("./lib/Digraph"),c.CGraph=a("./lib/CGraph"),c.CDigraph=a("./lib/CDigraph"),a("./lib/graph-converters"),c.alg={isAcyclic:a("./lib/alg/isAcyclic"),components:a("./lib/alg/components"),dijkstra:a("./lib/alg/dijkstra"),dijkstraAll:a("./lib/alg/dijkstraAll"),findCycles:a("./lib/alg/findCycles"),floydWarshall:a("./lib/alg/floydWarshall"),postorder:a("./lib/alg/postorder"),preorder:a("./lib/alg/preorder"),prim:a("./lib/alg/prim"),tarjan:a("./lib/alg/tarjan"),topsort:a("./lib/alg/topsort")},c.converter={json:a("./lib/converter/json.js")};var d=a("./lib/filter");c.filter={all:d.all,nodesFromList:d.nodesFromList},c.version=a("./lib/version")},{"./lib/CDigraph":30,"./lib/CGraph":31,"./lib/Digraph":32,"./lib/Graph":33,"./lib/alg/components":34,"./lib/alg/dijkstra":35,"./lib/alg/dijkstraAll":36,"./lib/alg/findCycles":37,"./lib/alg/floydWarshall":38,"./lib/alg/isAcyclic":39,"./lib/alg/postorder":40,"./lib/alg/preorder":41,"./lib/alg/prim":42,"./lib/alg/tarjan":43,"./lib/alg/topsort":44,"./lib/converter/json.js":46,"./lib/filter":47,"./lib/graph-converters":48,"./lib/version":50}],29:[function(a,b,c){function e(){this._value=undefined,this._nodes={},this._edges={},this._nextId=0}function f(a,b,c){(a[b]||(a[b]=new d)).add(
2
+ c)}function g(a,b,c){var d=a[b];d.remove(c),d.size()===0&&delete a[b]}var d=a("cp-data").Set;b.exports=e,e.prototype.order=function(){return Object.keys(this._nodes).length},e.prototype.size=function(){return Object.keys(this._edges).length},e.prototype.graph=function(a){if(arguments.length===0)return this._value;this._value=a},e.prototype.hasNode=function(a){return a in this._nodes},e.prototype.node=function(a,b){var c=this._strictGetNode(a);if(arguments.length===1)return c.value;c.value=b},e.prototype.nodes=function(){var a=[];return this.eachNode(function(b){a.push(b)}),a},e.prototype.eachNode=function(a){for(var b in this._nodes){var c=this._nodes[b];a(c.id,c.value)}},e.prototype.hasEdge=function(a){return a in this._edges},e.prototype.edge=function(a,b){var c=this._strictGetEdge(a);if(arguments.length===1)return c.value;c.value=b},e.prototype.edges=function(){var a=[];return this.eachEdge(function(b){a.push(b)}),a},e.prototype.eachEdge=function(a){for(var b in this._edges){var c=this._edges[b];a(c.id,c.u,c.v,c.value)}},e.prototype.incidentNodes=function(a){var b=this._strictGetEdge(a);return[b.u,b.v]},e.prototype.addNode=function(a,b){if(a===undefined||a===null){do a="_"+ ++this._nextId;while(this.hasNode(a))}else if(this.hasNode(a))throw new Error("Graph already has node '"+a+"'");return this._nodes[a]={id:a,value:b},a},e.prototype.delNode=function(a){this._strictGetNode(a),this.incidentEdges(a).forEach(function(a){this.delEdge(a)},this),delete this._nodes[a]},e.prototype._addEdge=function(a,b,c,d,e,g){this._strictGetNode(b),this._strictGetNode(c);if(a===undefined||a===null){do a="_"+ ++this._nextId;while(this.hasEdge(a))}else if(this.hasEdge(a))throw new Error("Graph already has edge '"+a+"'");return this._edges[a]={id:a,u:b,v:c,value:d},f(e[c],b,a),f(g[b],c,a),a},e.prototype._delEdge=function(a,b,c){var d=this._strictGetEdge(a);g(b[d.v],d.u,a),g(c[d.u],d.v,a),delete this._edges[a]},e.prototype.copy=function(){var a=new this.constructor;return a.graph(this.graph()),this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(b,c,d,e)}),a._nextId=this._nextId,a},e.prototype.filterNodes=function(a){var b=new this.constructor;return b.graph(this.graph()),this.eachNode(function(c,d){a(c)&&b.addNode(c,d)}),this.eachEdge(function(a,c,d,e){b.hasNode(c)&&b.hasNode(d)&&b.addEdge(a,c,d,e)}),b},e.prototype._strictGetNode=function(a){var b=this._nodes[a];if(b===undefined)throw new Error("Node '"+a+"' is not in graph");return b},e.prototype._strictGetEdge=function(a){var b=this._edges[a];if(b===undefined)throw new Error("Edge '"+a+"' is not in graph");return b}},{"cp-data":5}],30:[function(a,b,c){var d=a("./Digraph"),e=a("./compoundify"),f=e(d);b.exports=f,f.fromDigraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b},f.prototype.toString=function(){return"CDigraph "+JSON.stringify(this,null,2)}},{"./Digraph":32,"./compoundify":45}],31:[function(a,b,c){var d=a("./Graph"),e=a("./compoundify"),f=e(d);b.exports=f,f.fromGraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b},f.prototype.toString=function(){return"CGraph "+JSON.stringify(this,null,2)}},{"./Graph":33,"./compoundify":45}],32:[function(a,b,c){function g(){e.call(this),this._inEdges={},this._outEdges={}}var d=a("./util"),e=a("./BaseGraph"),f=a("cp-data").Set;b.exports=g,g.prototype=new e,g.prototype.constructor=g,g.prototype.isDirected=function(){return!0},g.prototype.successors=function(a){return this._strictGetNode(a),Object.keys(this._outEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.predecessors=function(a){return this._strictGetNode(a),Object.keys(this._inEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.neighbors=function(a){return f.union([this.successors(a),this.predecessors(a)]).keys()},g.prototype.sources=function(){var a=this;return this._filterNodes(function(b){return a.inEdges(b).length===0})},g.prototype.sinks=function(){var a=this;return this._filterNodes(function(b){return a.outEdges(b).length===0})},g.prototype.source=function(a){return this._strictGetEdge(a).u},g.prototype.target=function(a){return this._strictGetEdge(a).v},g.prototype.inEdges=function(a,b){this._strictGetNode(a);var c=f.union(d.values(this._inEdges[a])).keys();return arguments.length>1&&(this._strictGetNode(b),c=c.filter(function(a){return this.source(a)===b},this)),c},g.prototype.outEdges=function(a,b){this._strictGetNode(a);var c=f.union(d.values(this._outEdges[a])).keys();return arguments.length>1&&(this._strictGetNode(b),c=c.filter(function(a){return this.target(a)===b},this)),c},g.prototype.incidentEdges=function(a,b){return arguments.length>1?f.union([this.outEdges(a,b),this.outEdges(b,a)]).keys():f.union([this.inEdges(a),this.outEdges(a)]).keys()},g.prototype.toString=function(){return"Digraph "+JSON.stringify(this,null,2)},g.prototype.addNode=function(a,b){return a=e.prototype.addNode.call(this,a,b),this._inEdges[a]={},this._outEdges[a]={},a},g.prototype.delNode=function(a){e.prototype.delNode.call(this,a),delete this._inEdges[a],delete this._outEdges[a]},g.prototype.addEdge=function(a,b,c,d){return e.prototype._addEdge.call(this,a,b,c,d,this._inEdges,this._outEdges)},g.prototype.delEdge=function(a){e.prototype._delEdge.call(this,a,this._inEdges,this._outEdges)},g.prototype._filterNodes=function(a){var b=[];return this.eachNode(function(c){a(c)&&b.push(c)}),b}},{"./BaseGraph":29,"./util":49,"cp-data":5}],33:[function(a,b,c){function g(){e.call(this),this._incidentEdges={}}var d=a("./util"),e=a("./BaseGraph"),f=a("cp-data").Set;b.exports=g,g.prototype=new e,g.prototype.constructor=g,g.prototype.isDirected=function(){return!1},g.prototype.neighbors=function(a){return this._strictGetNode(a),Object.keys(this._incidentEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.incidentEdges=function(a,b){return this._strictGetNode(a),arguments.length>1?(this._strictGetNode(b),b in this._incidentEdges[a]?this._incidentEdges[a][b].keys():[]):f.union(d.values(this._incidentEdges[a])).keys()},g.prototype.toString=function(){return"Graph "+JSON.stringify(this,null,2)},g.prototype.addNode=function(a,b){return a=e.prototype.addNode.call(this,a,b),this._incidentEdges[a]={},a},g.prototype.delNode=function(a){e.prototype.delNode.call(this,a),delete this._incidentEdges[a]},g.prototype.addEdge=function(a,b,c,d){return e.prototype._addEdge.call(this,a,b,c,d,this._incidentEdges,this._incidentEdges)},g.prototype.delEdge=function(a){e.prototype._delEdge.call(this,a,this._incidentEdges,this._incidentEdges)}},{"./BaseGraph":29,"./util":49,"cp-data":5}],34:[function(a,b,c){function e(a){function e(b,d){c.has(b)||(c.add(b),d.push(b),a.neighbors(b).forEach(function(a){e(a,d)}))}var b=[],c=new d;return a.nodes().forEach(function(a){var c=[];e(a,c),c.length>0&&b.push(c)}),b}var d=a("cp-data").Set;b.exports=e},{"cp-data":5}],35:[function(a,b,c){function e(a,b,c,e){function h(b){var d=a.incidentNodes(b),e=d[0]!==i?d[0]:d[1],h=f[e],k=c(b),l=j.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+k);l<h.distance&&(h.distance=l,h.predecessor=i,g.decrease(e,l))}var f={},g=new d;c=c||function(){return 1},e=e||(a.isDirected()?function(b){return a.outEdges(b)}:function(b){return a.incidentEdges(b)}),a.eachNode(function(a){var c=a===b?0:Number.POSITIVE_INFINITY;f[a]={distance:c},g.add(a,c)});var i,j;while(g.size()>0){i=g.removeMin(),j=f[i];if(j.distance===Number.POSITIVE_INFINITY)break;e(i).forEach(h)}return f}var d=a("cp-data").PriorityQueue;b.exports=e},{"cp-data":5}],36:[function(a,b,c){function e(a,b,c){var e={};return a.eachNode(function(f){e[f]=d(a,f,b,c)}),e}var d=a("./dijkstra");b.exports=e},{"./dijkstra":35}],37:[function(a,b,c){function e(a){return d(a).filter(function(a){return a.length>1})}var d=a("./tarjan");b.exports=e},{"./tarjan":43}],38:[function(a,b,c){function d(a,b,c){var d={},e=a.nodes();return b=b||function(){return 1},c=c||(a.isDirected()?function(b){return a.outEdges(b)}:function(b){return a.incidentEdges(b)}),e.forEach(function(f){d[f]={},d[f][f]={distance:0},e.forEach(function(a){f!==a&&(d[f][a]={distance:Number.POSITIVE_INFINITY})}),c(f).forEach(function(c){var e=a.incidentNodes(c),h=e[0]!==f?e[0]:e[1],i=b(c);i<d[f][h].distance&&(d[f][h]={distance:i,predecessor:f})})}),e.forEach(function(a){var b=d[a];e.forEach(function(c){var f=d[c];e.forEach(function(c){var d=f[a],e=b[c],g=f[c],h=d.distance+e.distance;h<g.distance&&(g.distance=h,g.predecessor=e.predecessor)})})}),d}b.exports=d},{}],39:[function(a,b,c){function e(a){try{d(a)}catch(b){if(b instanceof d.CycleException)return!1;throw b}return!0}var d=a("./topsort");b.exports=e},{"./topsort":44}],40:[function(a,b,c){function e(a,b,c){function f(b,d){if(e.has(b))throw new Error("The input graph is not a tree: "+a);e.add(b),a.neighbors(b).forEach(function(a){a!==d&&f(a,b)}),c(b)}var e=new d;if(a.isDirected())throw new Error("This function only works for undirected graphs");f(b)}var d=a("cp-data").Set;b.exports=e},{"cp-data":5}],41:[function(a,b,c){function e(a,b,c){function f(b,d){if(e.has(b))throw new Error("The input graph is not a tree: "+a);e.add(b),c(b),a.neighbors(b).forEach(function(a){a!==d&&f(a,b)})}var e=new d;if(a.isDirected())throw new Error("This function only works for undirected graphs");f(b)}var d=a("cp-data").Set;b.exports=e},{"cp-data":5}],42:[function(a,b,c){function f(a,b){function i(c){var d=a.incidentNodes(c),e=d[0]!==h?d[0]:d[1],i=g.priority(e);if(i!==undefined){var j=b(c);j<i&&(f[e]=h,g.decrease(e,j))}}var c=new d,f={},g=new e,h;if(a.order()===0)return c;a.eachNode(function(a){g.add(a,Number.POSITIVE_INFINITY),c.addNode(a)}),g.decrease(a.nodes()[0],0);var j=!1;while(g.size()>0){h=g.removeMin();if(h in f)c.addEdge(null,h,f[h]);else{if(j)throw new Error("Input graph is not connected: "+a);j=!0}a.incidentEdges(h).forEach(i)}return c}var d=a("../Graph"),e=a("cp-data").PriorityQueue;b.exports=f},{"../Graph":33,"cp-data":5}],43:[function(a,b,c){function d(a){function f(h){var i=d[h]={onStack:!0,lowlink:b,index:b++};c.push(h),a.successors(h).forEach(function(a){a in d?d[a].onStack&&(i.lowlink=Math.min(i.lowlink,d[a].index)):(f(a),i.lowlink=Math.min(i.lowlink,d[a].lowlink))});if(i.lowlink===i.index){var j=[],k;do k=c.pop(),d[k].onStack=!1,j.push(k);while(h!==k);e.push(j)}}if(!a.isDirected())throw new Error("tarjan can only be applied to a directed graph. Bad input: "+a);var b=0,c=[],d={},e=[];return a.nodes().forEach(function(a){a in d||f(a)}),e}b.exports=d},{}],44:[function(a,b,c){function d(a){function f(g){if(g in c)throw new e;g in b||(c[g]=!0,b[g]=!0,a.predecessors(g).forEach(function(a){f(a)}),delete c[g],d.push(g))}if(!a.isDirected())throw new Error("topsort can only be applied to a directed graph. Bad input: "+a);var b={},c={},d=[],g=a.sinks();if(a.order()!==0&&g.length===0)throw new e;return a.sinks().forEach(function(a){f(a)}),d}function e(){}b.exports=d,d.CycleException=e,e.prototype.toString=function(){return"Graph has at least one cycle"}},{}],45:[function(a,b,c){function e(a){function b(){a.call(this),this._parents={},this._children={},this._children[null]=new d}return b.prototype=new a,b.prototype.constructor=b,b.prototype.parent=function(a,b){this._strictGetNode(a);if(arguments.length<2)return this._parents[a];if(a===b)throw new Error("Cannot make "+a+" a parent of itself");b!==null&&this._strictGetNode(b),this._children[this._parents[a]].remove(a),this._parents[a]=b,this._children[b].add(a)},b.prototype.children=function(a){return a!==null&&this._strictGetNode(a),this._children[a].keys()},b.prototype.addNode=function(b,c){return b=a.prototype.addNode.call(this,b,c),this._parents[b]=null,this._children[b]=new d,this._children[null].add(b),b},b.prototype.delNode=function(b){var c=this.parent(b);return this._children[b].keys().forEach(function(a){this.parent(a,c)},this),this._children[c].remove(b),delete this._parents[b],delete this._children[b],a.prototype.delNode.call(this,b)},b.prototype.copy=function(){var b=a.prototype.copy.call(this);return this.nodes().forEach(function(a){b.parent(a,this.parent(a))},this),b},b.prototype.filterNodes=function(b){function f(a){var b=c.parent(a);return b===null||d.hasNode(b)?(e[a]=b,b):b in e?e[b]:f(b)}var c=this,d=a.prototype.filterNodes.call(this,b),e={};return d.eachNode(function(a){d.parent(a,f(a))}),d},b}var d=a("cp-data").Set;b.exports=e},{"cp-data":5}],46:[function(a,b,c){function h(a){return Object.prototype.toString.call(a).slice(8,-1)}var d=a("../Graph"),e=a("../Digraph"),f=a("../CGraph"),g=a("../CDigraph");c.decode=function(a,b,c){c=c||e;if(h(a)!=="Array")throw new Error("nodes is not an Array");if(h(b)!=="Array")throw new Error("edges is not an Array");if(typeof c=="string")switch(c){case"graph":c=d;break;case"digraph":c=e;break;case"cgraph":c=f;break;case"cdigraph":c=g;break;default:throw new Error("Unrecognized graph type: "+c)}var i=new c;return a.forEach(function(a){i.addNode(a.id,a.value)}),i.parent&&a.forEach(function(a){a.children&&a.children.forEach(function(b){i.parent(b,a.id)})}),b.forEach(function(a){i.addEdge(a.id,a.u,a.v,a.value)}),i},c.encode=function(a){var b=[],c=[];a.eachNode(function(c,d){var e={id:c,value:d};if(a.children){var f=a.children(c);f.length&&(e.children=f)}b.push(e)}),a.eachEdge(function(a,b,d,e){c.push({id:a,u:b,v:d,value:e})});var h;if(a instanceof g)h="cdigraph";else if(a instanceof f)h="cgraph";else if(a instanceof e)h="digraph";else if(a instanceof d)h="graph";else throw new Error("Couldn't determine type of graph: "+a);return{nodes:b,edges:c,type:h}}},{"../CDigraph":30,"../CGraph":31,"../Digraph":32,"../Graph":33}],47:[function(a,b,c){var d=a("cp-data").Set;c.all=function(){return function(){return!0}},c.nodesFromList=function(a){var b=new d(a);return function(a){return b.has(a)}}},{"cp-data":5}],48:[function(a,b,c){var d=a("./Graph"),e=a("./Digraph");d.prototype.toDigraph=d.prototype.asDirected=function(){var a=new e;return this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(null,c,d,e),a.addEdge(null,d,c,e)}),a},e.prototype.toGraph=e.prototype.asUndirected=function(){var a=new d;return this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(b,c,d,e)}),a}},{"./Digraph":32,"./Graph":33}],49:[function(a,b,c){c.values=function(a){var b=Object.keys(a),c=b.length,d=new Array(c),e;for(e=0;e<c;++e)d[e]=a[b[e]];return d}},{}],50:[function(a,b,c){b.exports="0.7.4"},{}]},{},[1]);
@@ -0,0 +1,2 @@
1
+ (function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var j=typeof require=="function"&&require;if(!h&&j)return j(g,!0);if(f)return f(g,!0);throw new Error("Cannot find module '"+g+"'")}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}var f=typeof require=="function"&&require;for(var g=0;g<d.length;g++)e(d[g]);return e})({1:[function(a,b,c){var d=typeof self!="undefined"?self:typeof window!="undefined"?window:{};d.graphlibDot=a("./index")},{"./index":2}],2:[function(a,b,c){var d=a("./lib/parse"),e=a("./lib/write"),f=a("./lib/version");b.exports={DotGraph:a("./lib/DotGraph"),DotDigraph:a("./lib/DotDigraph"),parse:d,decode:d,parseMany:d.parseMany,write:e,encode:e,version:f,type:"dot",buffer:!1}},{"./lib/DotDigraph":3,"./lib/DotGraph":4,"./lib/parse":8,"./lib/version":9,"./lib/write":10}],3:[function(a,b,c){var d=a("graphlib").CDigraph,e=a("./dotify"),f=e(d);b.exports=f,f.fromDigraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b}},{"./dotify":7,graphlib:11}],4:[function(a,b,c){var d=a("graphlib").CGraph,e=a("./dotify"),f=e(d);b.exports=f,f.fromGraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b}},{"./dotify":7,graphlib:11}],5:[function(a,b,c){function e(){this._indent="",this._content="",this._shouldIndent=!0}b.exports=e;var d=" ";e.prototype.indent=function(){this._indent+=d},e.prototype.unindent=function(){this._indent=this._indent.slice(d.length)},e.prototype.writeLine=function(a){this.write((a||"")+"\n"),this._shouldIndent=!0},e.prototype.write=function(a){this._shouldIndent&&(this._shouldIndent=!1,this._content+=this._indent),this._content+=a},e.prototype.toString=function(){return this._content}},{}],6:[function(a,b,c){b.exports=function(){function a(a){return'"'+a.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g,escape)+'"'}var b={parse:function(b,c){function i(a,b,c){var d=a,e=c-a.length;for(var f=0;f<e;f++)d=b+d;return d}function j(a){var b=a.charCodeAt(0),c,d;return b<=255?(c="x",d=2):(c="u",d=4),"\\"+c+i(b.toString(16).toUpperCase(),"0",d)}function k(a){if(e<g)return;e>g&&(g=e,h=[]),h.push(a)}function l(){var a,b;b=m();if(b!==null){a=[];while(b!==null)a.push(b),b=m()}else a=null;return a}function m(){var a,c,d,g,h,i,j,l,m,o,p,q,r,s,t,u;s=e,t=e,a=[],c=N();while(c!==null)a.push(c),c=N();if(a!==null){u=e,c=J(),c!==null?(d=N(),d!==null?c=[c,d]:(c=null,e=u)):(c=null,e=u),c=c!==null?c:"";if(c!==null){d=K();if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();if(g!==null){h=D(),h=h!==null?h:"";if(h!==null){i=[],j=N();while(j!==null)i.push(j),j=N();if(i!==null){b.charCodeAt(e)===123?(j="{",e++):(j=null,f===0&&k('"{"'));if(j!==null){l=[],m=N();while(m!==null)l.push(m),m=N();if(l!==null){m=n(),m=m!==null?m:"";if(m!==null){o=[],p=N();while(p!==null)o.push(p),p=N();if(o!==null){b.charCodeAt(e)===125?(p="}",e++):(p=null,f===0&&k('"}"'));if(p!==null){q=[],r=N();while(r!==null)q.push(r),r=N();q!==null?a=[a,c,d,g,h,i,j,l,m,o,p,q]:(a=null,e=t)}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t}else a=null,e=t;return a!==null&&(a=function(a,b,c,d){return{type:b,id:c,stmts:d}}(s,a[2],a[4],a[8])),a===null&&(e=s),a}function n(){var a,c,d,g,h,i,j,l,m,n,p;m=e,n=e,a=o();if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){b.charCodeAt(e)===59?(d=";",e++):(d=null,f===0&&k('";"')),d=d!==null?d:"";if(d!==null){g=[],p=e,h=[],i=N();while(i!==null)h.push(i),i=N();if(h!==null){i=o();if(i!==null){j=[],l=N();while(l!==null)j.push(l),l=N();j!==null?(b.charCodeAt(e)===59?(l=";",e++):(l=null,f===0&&k('";"')),l=l!==null?l:"",l!==null?h=[h,i,j,l]:(h=null,e=p)):(h=null,e=p)}else h=null,e=p}else h=null,e=p;while(h!==null){g.push(h),p=e,h=[],i=N();while(i!==null)h.push(i),i=N();if(h!==null){i=o();if(i!==null){j=[],l=N();while(l!==null)j.push(l),l=N();j!==null?(b.charCodeAt(e)===59?(l=";",e++):(l=null,f===0&&k('";"')),l=l!==null?l:"",l!==null?h=[h,i,j,l]:(h=null,e=p)):(h=null,e=p)}else h=null,e=p}else h=null,e=p}g!==null?a=[a,c,d,g]:(a=null,e=n)}else a=null,e=n}else a=null,e=n}else a=null,e=n;return a!==null&&(a=function(a,b,c){var d=[b];for(var e=0;e<c.length;++e)d.push(c[e][1]);return d}(m,a[0],a[3])),a===null&&(e=m),a}function o(){var a;return a=p(),a===null&&(a=s(),a===null&&(a=t(),a===null&&(a=q(),a===null&&(a=r())))),a}function p(){var a,b,c,d,f;d=e,f=e,a=G(),a===null&&(a=E(),a===null&&(a=F()));if(a!==null){b=[],c=N();while(c!==null)b.push(c),c=N();b!==null?(c=u(),c!==null?a=[a,b,c]:(a=null,e=f)):(a=null,e=f)}else a=null,e=f;return a!==null&&(a=function(a,b,c){return{type:"attr",attrType:b,attrs:c||{}}}(d,a[0],a[2])),a===null&&(e=d),a}function q(){var a,c,d,g,h,i,j;i=e,j=e,a=D();if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){b.charCodeAt(e)===61?(d="=",e++):(d=null,f===0&&k('"="'));if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();g!==null?(h=D(),h!==null?a=[a,c,d,g,h]:(a=null,e=j)):(a=null,e=j)}else a=null,e=j}else a=null,e=j}else a=null,e=j;return a!==null&&(a=function(a,b,c){var d={};return d[b]=c,{type:"inlineAttr",attrs:d}}(i,a[0],a[4])),a===null&&(e=i),a}function r(){var a,b,c,d,f;d=e,f=e,a=A();if(a!==null){b=[],c=N();while(c!==null)b.push(c),c=N();b!==null?(c=u(),c=c!==null?c:"",c!==null?a=[a,b,c]:(a=null,e=f)):(a=null,e=f)}else a=null,e=f;return a!==null&&(a=function(a,b,c){return{type:"node",id:b,attrs:c||{}}}(d,a[0],a[2])),a===null&&(e=d),a}function s(){var a,b,c,d,f,g,h;g=e,h=e,a=z();if(a!==null){b=[],c=N();while(c!==null)b.push(c),c=N();if(b!==null){c=x();if(c!==null){d=[],f=N();while(f!==null)d.push(f),f=N();d!==null?(f=u(),f=f!==null?f:"",f!==null?a=[a,b,c,d,f]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h}else a=null,e=h}else a=null,e=h;return a!==null&&(a=function(a,b,c,d){var e=[b];for(var f=0;f<c.length;++f)e.push(c[f]);return{type:"edge",elems:e,attrs:d||{}}}(g,a[0],a[2],a[4])),a===null&&(e=g),a}function t(){var a,c,d,g,h,i,j,l,m,o;j=e,l=e,m=e,a=I();if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){o=e,d=D();if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();g!==null?d=[d,g]:(d=null,e=o)}else d=null,e=o;d=d!==null?d:"",d!==null?a=[a,c,d]:(a=null,e=m)}else a=null,e=m}else a=null,e=m;a=a!==null?a:"";if(a!==null){b.charCodeAt(e)===123?(c="{",e++):(c=null,f===0&&k('"{"'));if(c!==null){d=[],g=N();while(g!==null)d.push(g),g=N();if(d!==null){g=n(),g=g!==null?g:"";if(g!==null){h=[],i=N();while(i!==null)h.push(i),i=N();h!==null?(b.charCodeAt(e)===125?(i="}",e++):(i=null,f===0&&k('"}"')),i!==null?a=[a,c,d,g,h,i]:(a=null,e=l)):(a=null,e=l)}else a=null,e=l}else a=null,e=l}else a=null,e=l}else a=null,e=l;return a!==null&&(a=function(a,b,c){return b=b[2]||[],{type:"subgraph",id:b[0],stmts:c}}(j,a[0],a[3])),a===null&&(e=j),a}function u(){var a,b,c,d,f,g,h;f=e,g=e,a=v();if(a!==null){b=[],h=e,c=[],d=N();while(d!==null)c.push(d),d=N();c!==null?(d=v(),d!==null?c=[c,d]:(c=null,e=h)):(c=null,e=h);while(c!==null){b.push(c),h=e,c=[],d=N();while(d!==null)c.push(d),d=N();c!==null?(d=v(),d!==null?c=[c,d]:(c=null,e=h)):(c=null,e=h)}b!==null?a=[a,b]:(a=null,e=g)}else a=null,e=g;return a!==null&&(a=function(a,b,c){var d=b;for(var e=0;e<c.length;++e)d=R(d,c[e][1]);return d}(f,a[0],a[1])),a===null&&(e=f),a}function v(){var a,c,d,g,h,i,j;i=e,j=e,b.charCodeAt(e)===91?(a="[",e++):(a=null,f===0&&k('"["'));if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){d=w(),d=d!==null?d:"";if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();g!==null?(b.charCodeAt(e)===93?(h="]",e++):(h=null,f===0&&k('"]"')),h!==null?a=[a,c,d,g,h]:(a=null,e=j)):(a=null,e=j)}else a=null,e=j}else a=null,e=j}else a=null,e=j;return a!==null&&(a=function(a,b){return b}(i,a[2])),a===null&&(e=i),a}function w(){var a,c,d,g,h,i,j,l,m;j=e,l=e,a=y();if(a!==null){c=[],m=e,d=[],g=N();while(g!==null)d.push(g),g=N();if(d!==null){b.charCodeAt(e)===44?(g=",",e++):(g=null,f===0&&k('","')),g=g!==null?g:"";if(g!==null){h=[],i=N();while(i!==null)h.push(i),i=N();h!==null?(i=y(),i!==null?d=[d,g,h,i]:(d=null,e=m)):(d=null,e=m)}else d=null,e=m}else d=null,e=m;while(d!==null){c.push(d),m=e,d=[],g=N();while(g!==null)d.push(g),g=N();if(d!==null){b.charCodeAt(e)===44?(g=",",e++):(g=null,f===0&&k('","')),g=g!==null?g:"";if(g!==null){h=[],i=N();while(i!==null)h.push(i),i=N();h!==null?(i=y(),i!==null?d=[d,g,h,i]:(d=null,e=m)):(d=null,e=m)}else d=null,e=m}else d=null,e=m}c!==null?a=[a,c]:(a=null,e=l)}else a=null,e=l;return a!==null&&(a=function(a,b,c){var d=b;for(var e=0;e<c.length;++e)d=R(d,c[e][3]);return d}(j,a[0],a[1])),a===null&&(e=j),a}function x(){var a,c,d,g,h,i,j,l;i=e,j=e,l=e,b.substr(e,2)==="--"?(a="--",e+=2):(a=null,f===0&&k('"--"')),a!==null?(c=function(a){return Q}(e)?null:"",c!==null?a=[a,c]:(a=null,e=l)):(a=null,e=l),a===null&&(l=e,b.substr(e,2)==="->"?(a="->",e+=2):(a=null,f===0&&k('"->"')),a!==null?(c=function(a){return Q}(e)?"":null,c!==null?a=[a,c]:(a=null,e=l)):(a=null,e=l));if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){d=z();if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();g!==null?(h=x(),h=h!==null?h:"",h!==null?a=[a,c,d,g,h]:(a=null,e=j)):(a=null,e=j)}else a=null,e=j}else a=null,e=j}else a=null,e=j;return a!==null&&(a=function(a,b,c){var d=[b];for(var e=0;e<c.length;++e)d.push(c[e]);return d}(i,a[2],a[4])),a===null&&(e=i),a}function y(){var a,c,d,g,h,i,j,l;i=e,j=e,a=D();if(a!==null){l=e,c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){b.charCodeAt(e)===61?(d="=",e++):(d=null,f===0&&k('"="'));if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();g!==null?(h=D(),h!==null?c=[c,d,g,h]:(c=null,e=l)):(c=null,e=l)}else c=null,e=l}else c=null,e=l;c=c!==null?c:"",c!==null?a=[a,c]:(a=null,e=j)}else a=null,e=j;return a!==null&&(a=function(a,b,c){var d={};return d[b]=c[3],d}(i,a[0],a[1])),a===null&&(e=i),a}function z(){var a,b;return a=t(),a===null&&(b=e,a=A(),a!==null&&(a=function(a,b){return{type:"node",id:b,attrs:{}}}(b,a)),a===null&&(e=b)),a}function A(){var a,b,c,d,f;d=e,f=e,a=D();if(a!==null){b=[],c=N();while(c!==null)b.push(c),c=N();b!==null?(c=B(),c=c!==null?c:"",c!==null?a=[a,b,c]:(a=null,e=f)):(a=null,e=f)}else a=null,e=f;return a!==null&&(a=function(a,b){return b}(d,a[0])),a===null&&(e=d),a}function B(){var a,c,d,g,h,i,j,l,m;l=e,b.charCodeAt(e)===58?(a=":",e++):(a=null,f===0&&k('":"'));if(a!==null){c=[],d=N();while(d!==null)c.push(d),d=N();if(c!==null){d=D();if(d!==null){g=[],h=N();while(h!==null)g.push(h),h=N();if(g!==null){m=e,b.charCodeAt(e)===58?(h=":",e++):(h=null,f===0&&k('":"'));if(h!==null){i=[],j=N();while(j!==null)i.push(j),j=N();i!==null?(j=C(),j!==null?h=[h,i,j]:(h=null,e=m)):(h=null,e=m)}else h=null,e=m;h=h!==null?h:"",h!==null?a=[a,c,d,g,h]:(a=null,e=l)}else a=null,e=l}else a=null,e=l}else a=null,e=l}else a=null,e=l;return a}function C(){var a;return b.substr(e,2)==="ne"?(a="ne",e+=2):(a=null,f===0&&k('"ne"')),a===null&&(b.substr(e,2)==="se"?(a="se",e+=2):(a=null,f===0&&k('"se"')),a===null&&(b.substr(e,2)==="sw"?(a="sw",e+=2):(a=null,f===0&&k('"sw"')),a===null&&(b.substr(e,2)==="nw"?(a="nw",e+=2):(a=null,f===0&&k('"nw"')),a===null&&(b.charCodeAt(e)===110?(a="n",e++):(a=null,f===0&&k('"n"')),a===null&&(b.charCodeAt(e)===101?(a="e",e++):(a=null,f===0&&k('"e"')),a===null&&(b.charCodeAt(e)===115?(a="s",e++):(a=null,f===0&&k('"s"')),a===null&&(b.charCodeAt(e)===119?(a="w",e++):(a=null,f===0&&k('"w"')),a===null&&(b.charCodeAt(e)===99?(a="c",e++):(a=null,f===0&&k('"c"')),a===null&&(b.charCodeAt(e)===95?(a="_",e++):(a=null,f===0&&k('"_"'))))))))))),a}function D(){var a,c,d,g,h,i,j,l,m;f++,i=e,j=e,/^[a-zA-Z\u0200-\u0377_]/.test(b.charAt(e))?(a=b.charAt(e),e++):(a=null,f===0&&k("[a-zA-Z\\u0200-\\u0377_]"));if(a!==null){c=[],/^[a-zA-Z\u0200-\u0377_0-9]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[a-zA-Z\\u0200-\\u0377_0-9]"));while(d!==null)c.push(d),/^[a-zA-Z\u0200-\u0377_0-9]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[a-zA-Z\\u0200-\\u0377_0-9]"));c!==null?a=[a,c]:(a=null,e=j)}else a=null,e=j;a!==null&&(a=function(a,b,c){return b+c.join("")}(i,a[0],a[1])),a===null&&(e=i);if(a===null){i=e,j=e,b.charCodeAt(e)===45?(a="-",e++):(a=null,f===0&&k('"-"')),a=a!==null?a:"";if(a!==null){b.charCodeAt(e)===46?(c=".",e++):(c=null,f===0&&k('"."'));if(c!==null){/^[0-9]/.test(b.charAt(e))?(g=b.charAt(e),e++):(g=null,f===0&&k("[0-9]"));if(g!==null){d=[];while(g!==null)d.push(g),/^[0-9]/.test(b.charAt(e))?(g=b.charAt(e),e++):(g=null,f===0&&k("[0-9]"))}else d=null;d!==null?a=[a,c,d]:(a=null,e=j)}else a=null,e=j}else a=null,e=j;a!==null&&(a=function(a,b,c,d){return b+c+d.join("")}(i,a[0],a[1],a[2])),a===null&&(e=i);if(a===null){i=e,j=e,b.charCodeAt(e)===45?(a="-",e++):(a=null,f===0&&k('"-"')),a=a!==null?a:"";if(a!==null){/^[0-9]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[0-9]"));if(d!==null){c=[];while(d!==null)c.push(d),/^[0-9]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[0-9]"))}else c=null;if(c!==null){l=e,b.charCodeAt(e)===46?(d=".",e++):(d=null,f===0&&k('"."'));if(d!==null){g=[],/^[0-9]/.test(b.charAt(e))?(h=b.charAt(e),e++):(h=null,f===0&&k("[0-9]"));while(h!==null)g.push(h),/^[0-9]/.test(b.charAt(e))?(h=b.charAt(e),e++):(h=null,f===0&&k("[0-9]"));g!==null?d=[d,g]:(d=null,e=l)}else d=null,e=l;d=d!==null?d:"",d!==null?a=[a,c,d]:(a=null,e=j)}else a=null,e=j}else a=null,e=j;a!==null&&(a=function(a,b,c,d){return b+c.join("")+(d[0]||"")+(d[1]||[]).join("")}(i,a[0],a[1],a[2])),a===null&&(e=i);if(a===null){i=e,j=e,b.charCodeAt(e)===34?(a='"',e++):(a=null,f===0&&k('"\\""'));if(a!==null){c=[],l=e,b.substr(e,2)==='\\"'?(d='\\"',e+=2):(d=null,f===0&&k('"\\\\\\""')),d!==null&&(d=function(a){return'"'}(l)),d===null&&(e=l),d===null&&(l=e,m=e,b.charCodeAt(e)===92?(d="\\",e++):(d=null,f===0&&k('"\\\\"')),d!==null?(/^[^"]/.test(b.charAt(e))?(g=b.charAt(e),e++):(g=null,f===0&&k('[^"]')),g!==null?d=[d,g]:(d=null,e=m)):(d=null,e=m),d!==null&&(d=function(a,b){return"\\"+b}(l,d[1])),d===null&&(e=l),d===null&&(/^[^"]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k('[^"]'))));while(d!==null)c.push(d),l=e,b.substr(e,2)==='\\"'?(d='\\"',e+=2):(d=null,f===0&&k('"\\\\\\""')),d!==null&&(d=function(a){return'"'}(l)),d===null&&(e=l),d===null&&(l=e,m=e,b.charCodeAt(e)===92?(d="\\",e++):(d=null,f===0&&k('"\\\\"')),d!==null?(/^[^"]/.test(b.charAt(e))?(g=b.charAt(e),e++):(g=null,f===0&&k('[^"]')),g!==null?d=[d,g]:(d=null,e=m)):(d=null,e=m),d!==null&&(d=function(a,b){return"\\"+b}(l,d[1])),d===null&&(e=l),d===null&&(/^[^"]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k('[^"]'))));c!==null?(b.charCodeAt(e)===34?(d='"',e++):(d=null,f===0&&k('"\\""')),d!==null?a=[a,c,d]:(a=null,e=j)):(a=null,e=j)}else a=null,e=j;a!==null&&(a=function(a,b){return b.join("")}(i,a[1])),a===null&&(e=i)}}}return f--,f===0&&a===null&&k("identifier"),a}function E(){var a,c;return c=e,b.substr(e,4).toLowerCase()==="node"?(a=b.substr(e,4),e+=4):(a=null,f===0&&k('"node"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function F(){var a,c;return c=e,b.substr(e,4).toLowerCase()==="edge"?(a=b.substr(e,4),e+=4):(a=null,f===0&&k('"edge"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function G(){var a,c;return c=e,b.substr(e,5).toLowerCase()==="graph"?(a=b.substr(e,5),e+=5):(a=null,f===0&&k('"graph"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function H(){var a,c;return c=e,b.substr(e,7).toLowerCase()==="digraph"?(a=b.substr(e,7),e+=7):(a=null,f===0&&k('"digraph"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function I(){var a,c;return c=e,b.substr(e,8).toLowerCase()==="subgraph"?(a=b.substr(e,8),e+=8):(a=null,f===0&&k('"subgraph"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function J(){var a,c;return c=e,b.substr(e,6).toLowerCase()==="strict"?(a=b.substr(e,6),e+=6):(a=null,f===0&&k('"strict"')),a!==null&&(a=function(a,b){return b.toLowerCase()}(c,a)),a===null&&(e=c),a}function K(){var a,b;return a=G(),a===null&&(b=e,a=H(),a!==null&&(a=function(a,b){return Q=b==="digraph",b}(b,a)),a===null&&(e=b)),a}function L(){var a,c;f++,/^[ \t\r\n]/.test(b.charAt(e))?(c=b.charAt(e),e++):(c=null,f===0&&k("[ \\t\\r\\n]"));if(c!==null){a=[];while(c!==null)a.push(c),/^[ \t\r\n]/.test(b.charAt(e))?(c=b.charAt(e),e++):(c=null,f===0&&k("[ \\t\\r\\n]"))}else a=null;return f--,f===0&&a===null&&k("whitespace"),a}function M(){var a,c,d,g,h,i,j;f++,h=e,b.substr(e,2)==="//"?(a="//",e+=2):(a=null,f===0&&k('"//"'));if(a!==null){c=[],/^[^\n]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[^\\n]"));while(d!==null)c.push(d),/^[^\n]/.test(b.charAt(e))?(d=b.charAt(e),e++):(d=null,f===0&&k("[^\\n]"));c!==null?a=[a,c]:(a=null,e=h)}else a=null,e=h;if(a===null){h=e,b.substr(e,2)==="/*"?(a="/*",e+=2):(a=null,f===0&&k('"/*"'));if(a!==null){c=[],i=e,j=e,f++,b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);while(d!==null)c.push(d),i=e,j=e,f++,b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),f--,d===null?d="":(d=null,e=j),d!==null?(b.length>e?(g=b.charAt(e),e++):(g=null,f===0&&k("any character")),g!==null?d=[d,g]:(d=null,e=i)):(d=null,e=i);c!==null?(b.substr(e,2)==="*/"?(d="*/",e+=2):(d=null,f===0&&k('"*/"')),d!==null?a=[a,c,d]:(a=null,e=h)):(a=null,e=h)}else a=null,e=h}return f--,f===0&&a===null&&k("comment"),a}function N(){var a;return a=L(),a===null&&(a=M()),a}function O(a){a.sort();var b=null,c=[];for(var d=0;d<a.length;d++)a[d]!==b&&(c.push(a[d]),b=a[d]);return c}function P(){var a=1,c=1,d=!1;for(var f=0;f<Math.max(e,g);f++){var h=b.charAt(f);h==="\n"?(d||a++,c=1,d=!1):h==="\r"||h==="\u2028"||h==="\u2029"?(a++,c=1,d=!0):(c++,d=!1)}return{line:a,column:c}}function R(a,b){var c={};for(var d in a)c[d]=a[d];for(var d in b)c[d]=b[d];return c}var d={start:l,graphStmt:m,stmtList:n,stmt:o,attrStmt:p,inlineAttrStmt:q,nodeStmt:r,edgeStmt:s,subgraphStmt:t,attrList:u,attrListBlock:v,aList:w,edgeRHS:x,idDef:y,nodeIdOrSubgraph:z,nodeId:A,port:B,compassPt:C,id:D,node:E,edge:F,graph:G,digraph:H,subgraph:I,strict:J,graphType:K,whitespace:L,comment:M,_:N};if(c!==undefined){if(d[c]===undefined)throw new Error("Invalid rule name: "+a(c)+".")}else c="start";var e=0,f=0,g=0,h=[],Q,S=d[c]();if(S===null||e!==b.length){var T=Math.max(e,g),U=T<b.length?b.charAt(T):null,V=P();throw new this.SyntaxError(O(h),U,T,V.line,V.column)}return S},toSource:function(){return this._source}};return b.SyntaxError=function(b,c,d,e,f){function g(b,c){var d,e;switch(b.length){case 0:d="end of input";break;case 1:d=b[0];break;default:d=b.slice(0,b.length-1).join(", ")+" or "+b[b.length-1]}return e=c?a(c):"end of input","Expected "+d+" but "+e+" found."}this.name="SyntaxError",this.expected=b,this.found=c,this.message=g(b,c),this.offset=d,this.line=e,this.column=f},b.SyntaxError.prototype=Error.prototype,b}()},{}],7:[function(a,b,c){function d(a){function b(){a.call(this),this.graph({})}return b.prototype=new a,b.prototype.constructor=b,b.prototype.graph=function(b){return arguments.length<1?a.prototype.graph.call(this):(this._checkValueType(b),a.prototype.graph.call(this,b))},b.prototype.node=function(b,c){return arguments.length<2?a.prototype.node.call(this,b):(this._checkValueType(c),a.prototype.node.call(this,b,c))},b.prototype.addNode=function(b,c){return arguments.length<2&&(c={}),this._checkValueType(c),a.prototype.addNode.call(this,b,c)},b.prototype.edge=function(b,c){return arguments.length<2?a.prototype.edge.call(this,b):(this._checkValueType(c),a.prototype.edge.call(this,b,c))},b.prototype.addEdge=function(b,c,d,e){return arguments.length<4&&(e={}),this._checkValueType(e),a.prototype.addEdge.call(this,b,c,d,e)},b.prototype._checkValueType=function(a){if(a===null||typeof a!="object")throw new Error("Value must be non-null and of type 'object'")},b}b.exports=d},{}],8:[function(a,b,c){function g(a){var b=f.parse(a,"graphStmt");return i(b)}function h(a){var b=f.parse(a);return b.map(function(a){return i(a)})}function i(a){function c(a,c,d){b.hasNode(a)||(b.addNode(a,h.get("node",{})),b.node(a).label===undefined&&(b.node(a).label=a),d!==null&&b.parent(a,d)),c&&j(c,b.node(a))}function f(a,c,d){var e={};j(h.get("edge",d),e);var f=d.id?d.id:null;b.addEdge(f,a,c,e)}function g(a){function e(a){c.push(a)}var b={},c=[],d;e(a);while(c.length!==0){d=c.pop();switch(d.type){case"node":b[d.id]=!0;break;case"edge":d.elems.forEach(e);break;case"subgraph":d.stmts.forEach(e)}}return Object.keys(b)}function i(a,d){var e=a.attrs;switch(a.type){case"node":c(a.id,e,d);break;case"edge":var k,l;a.elems.forEach(function(a){i(a,d);switch(a.type){case"node":l=[a.id];break;case"subgraph":l=g(a);break;default:throw new Error("Unsupported type incident on edge: "+a.type)}k&&k.forEach(function(a){l.forEach(function(b){f(a,b,e)})}),k=l});break;case"subgraph":h.enterSubDigraph(),a.id=b.addNode(a.id),d!==null&&b.parent(a.id,d),a.stmts&&a.stmts.forEach(function(b){i(b,a.id)}),b.children(a.id).length===0&&b.delNode(a.id),h.exitSubDigraph();break;case"attr":h.set(a.attrType,e);break;case"inlineAttr":a.attrs&&j(e,d===null?b.graph():b.node(d));break;default:throw new Error("Unsupported statement type: "+a.type)}}var b=a.type==="graph"?new e:new d,h={_default:{},get:function(b,c){if(typeof this._default[b]!="undefined"){var d={};return j(this._default[b],d),j(c,d),d}return c},set:function(b,c){this._default[b]=this.get(b,c)},enterSubDigraph:function(){function a(){}a.prototype=this._default;var b=new a;this._default=b},exitSubDigraph:function(){this._default=Object.getPrototypeOf(this._default)}};return a.stmts&&a.stmts.forEach(function(a){i(a,null)}),b}function j(a,b){Object.keys(a).forEach(function(c){b[c]=a[c]})}var d=a("./DotDigraph"),e=a("./DotGraph"),f=a("./dot-grammar");b.exports=g,b.exports.parseMany=h},{"./DotDigraph":3,"./DotGraph":4,"./dot-grammar":6}],9:[function(a,b,c){b.exports="0.4.10"},{}],10:[function(a,b,c){function f(a){var b=a.isDirected()?"->":"--",c=new d;c.writeLine((a.isDirected()?"digraph":"graph")+" {"),c.indent();var e=a.graph();return e&&Object.keys(e).map(function(a){c.writeLine(h(a)+"="+h(e[a])+";")}),g(a,null,c),a.edges().forEach(function(d){j(a,d,b,c)}),c.unindent(),c.writeLine("}"),c.toString()}function g(a,b,c){var d=a.children?a.children(b):b===null?a.nodes():[];d.forEach(function(b){if(!a.children||a.children(b).length===0)i(a,b,c);else{c.writeLine("subgraph "+h(b)+" {"),c.indent();var d=a.node(b);Object.keys(d).map(function(a){c.writeLine(h(a)+"="+h(d[a])+";")}),g(a,b,c),c.unindent(),c.writeLine("}")}})}function h(a){return typeof a=="number"||a.toString().match(e)?a:'"'+a.toString().replace(/"/g,'\\"')+'"'}function i(a,b,c){var d=a.node(b);c.write(h(b));if(d){var e=Object.keys(d).map(function(a){return h(a)+"="+h(d[a])});e.length&&c.write(" ["+e.join(",")+"]")}c.writeLine()}function j(a,b,c,d){var e=a.edge(b),f=a.incidentNodes(b),g=f[0],i=f[1];d.write(h(g)+" "+c+" "+h(i));if(e){var j=Object.keys(e).map(function(a){return h(a)+"="+h(e[a])});j.length&&d.write(" ["+j.join(",")+"]")}d.writeLine()}var d=a("./Writer");b.exports=f;var e=/^[a-zA-Z\200-\377_][a-zA-Z\200-\377_0-9]*$/},{"./Writer":5}],11:[function(a,b,c){c.Graph=a("./lib/Graph"),c.Digraph=a("./lib/Digraph"),c.CGraph=a("./lib/CGraph"),c.CDigraph=a("./lib/CDigraph"),a("./lib/graph-converters"),c.alg={isAcyclic:a("./lib/alg/isAcyclic"),components:a("./lib/alg/components"),dijkstra:a("./lib/alg/dijkstra"),dijkstraAll:a("./lib/alg/dijkstraAll"),findCycles:a("./lib/alg/findCycles"),floydWarshall:a("./lib/alg/floydWarshall"),postorder:a("./lib/alg/postorder"),preorder:a("./lib/alg/preorder"),prim:a("./lib/alg/prim"),tarjan:a("./lib/alg/tarjan"),topsort:a("./lib/alg/topsort")},c.converter={json:a("./lib/converter/json.js")};var d=a("./lib/filter");c.filter={all:d.all,nodesFromList:d.nodesFromList},c.version=a("./lib/version")},{"./lib/CDigraph":13,"./lib/CGraph":14,"./lib/Digraph":15,"./lib/Graph":16,"./lib/alg/components":17,"./lib/alg/dijkstra":18,"./lib/alg/dijkstraAll":19,"./lib/alg/findCycles":20,"./lib/alg/floydWarshall":21,"./lib/alg/isAcyclic":22,"./lib/alg/postorder":23,"./lib/alg/preorder":24,"./lib/alg/prim":25,"./lib/alg/tarjan":26,"./lib/alg/topsort":27,"./lib/converter/json.js":29,"./lib/filter":30,"./lib/graph-converters":31,"./lib/version":33}],12:[function(a,b,c){function e(){this._value=undefined,this._nodes={},this._edges={},this._nextId=0}function f(a,b,c){(a[b]||(a[b]=new d)).add(c)}function g(a,b,c){var d=a[b];d.remove(c),d.size()===0&&delete a[b]}var d=a("cp-data").Set;b.exports=e,e.prototype.order=function(){return Object.keys(this._nodes).length},e.prototype.size=function(){return Object.keys(this._edges).length},e.prototype.graph=function(a){if(arguments.length===0)return this._value;this._value=a},e.prototype.hasNode=function(a){return a in this._nodes},e.prototype.node=function(a,b){var c=this._strictGetNode(a);if(arguments.length===1)return c.value;c.value=b},e.prototype.nodes=function(){var a=[];return this.eachNode(function(b){a.push(b)}),a},e.prototype.eachNode=function(a){for(var b in this._nodes){var c=this._nodes[b];a(c.id,c.value)}},e.prototype.hasEdge=function(a){return a in this._edges},e.prototype.edge=function(a,b){var c=this._strictGetEdge(a);if(arguments.length===1)return c.value;c.value=b},e.prototype.edges=function(){var a=[];return this.eachEdge(function(b){a.push(b)}),a},e.prototype.eachEdge=function(a){for(var b in this._edges){var c=this._edges[b];a(c.id,c.u,c.v,c.value)}},e.prototype.incidentNodes=function(a){var b=this._strictGetEdge(a);return[b.u,b.v]},e.prototype.addNode=function(a,b){if(a===undefined||a===null){do a="_"+ ++this._nextId;while(this.hasNode(a))}else if(this.hasNode(a))throw new Error("Graph already has node '"+a+"'");return this._nodes[a]={id:a,value:b},a},e.prototype.delNode=function(a){this._strictGetNode(a),this.incidentEdges(a).forEach(function(a){this.delEdge(a)},this),delete this._nodes[a]},e.prototype._addEdge=function(a,b,c,d,e,g){this._strictGetNode(b),this._strictGetNode(c);if(a===undefined||a===null){do a="_"+ ++this._nextId;while(this.hasEdge(a))}else if(this.hasEdge(a))throw new Error("Graph already has edge '"+a+"'");return this._edges[a]={id:a,u:b,v:c,value:d},f(e[c],b,a),f(g[b],c,a),a},e.prototype._delEdge=function(a,b,c){var d=this._strictGetEdge(a);g(b[d.v],d.u,a),g(c[d.u],d.v,a),delete this._edges[a]},e.prototype.copy=function(){var a=new this.constructor;return a.graph(this.graph()),this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(b,c,d,e)}),a._nextId=this._nextId,a},e.prototype.filterNodes=function(a){var b=new this.constructor;return b.graph(this.graph()),this.eachNode(function(c,d){a(c)&&b.addNode(c,d)}),this.eachEdge(function(a,c,d,e){b.hasNode(c)&&b.hasNode(d)&&b.addEdge(a,c,d,e)}),b},e.prototype._strictGetNode=function(a){var b=this._nodes[a];if(b===undefined)throw new Error("Node '"+a+"' is not in graph");return b},e.prototype._strictGetEdge=function(a){var b=this._edges[a];if(b===undefined)throw new Error("Edge '"+a+"' is not in graph");return b}},{"cp-data":34}],13:[function(a,b,c){var d=a("./Digraph"),e=a("./compoundify"),f=e(d);b.exports=f,f.fromDigraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b},f.prototype.toString=function(){return"CDigraph "+JSON.stringify(this,null,2)}},{"./Digraph":15,"./compoundify":28}],14:[function(a,b,c){var d=a("./Graph"),e=a("./compoundify"),f=e(d);b.exports=f,f.fromGraph=function(a){var b=new f,c=a.graph();return c!==undefined&&b.graph(c),a.eachNode(function(a,c){c===undefined?b.addNode(a):b.addNode(a,c)}),a.eachEdge(function(a,c,d,e){e===undefined?b.addEdge(null,c,d):b.addEdge(null,c,d,e)}),b},f.prototype.toString=function(){return"CGraph "+JSON.stringify(this,null,2)}},{"./Graph":16,"./compoundify":28}],15:[function(a,b,c){function g(){e.call(this),this._inEdges={},this._outEdges={}}var d=a("./util"),e=a("./BaseGraph"),f=a("cp-data").Set;b.exports=g,g.prototype=new e,g.prototype.constructor=g,g.prototype.isDirected=function(){return!0},g.prototype.successors=function(a){return this._strictGetNode(a),Object.keys(this._outEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.predecessors=function(a){return this._strictGetNode(a),Object.keys(this._inEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.neighbors=function(a){return f.union([this.successors(a),this.predecessors(a)]).keys()},g.prototype.sources=function(){var a=this;return this._filterNodes(function(b){return a.inEdges(b).length===0})},g.prototype.sinks=function(){var a=this;return this._filterNodes(function(b){return a.outEdges(b).length===0})},g.prototype.source=function(a){return this._strictGetEdge(a).u},g.prototype.target=function(a){return this._strictGetEdge(a).v},g.prototype.inEdges=function(a,b){this._strictGetNode(a);var c=f.union(d.values(this._inEdges[a])).keys();return arguments.length>1&&(this._strictGetNode(b),c=c.filter(function(a){return this.source(a)===b},this)),c},g.prototype.outEdges=function(a,b){this._strictGetNode(a);var c=f.union(d.values(this._outEdges[a])).keys();return arguments.length>1&&(this._strictGetNode(b),c=c.filter(function(a){return this.target(a)===b},this)),c},g.prototype.incidentEdges=function(a,b){return arguments.length>1?f.union([this.outEdges(a,b),this.outEdges(b,a)]).keys():f.union([this.inEdges(a),this.outEdges(a)]).keys()},g.prototype.toString=function(){return"Digraph "+JSON.stringify(this,null,2)},g.prototype.addNode=function(a,b){return a=e.prototype.addNode.call(this,a,b),this._inEdges[a]={},this._outEdges[a]={},a},g.prototype.delNode=function(a){e.prototype.delNode.call(this,a),delete this._inEdges[a],delete this._outEdges[a]},g.prototype.addEdge=function(a,b,c,d){return e.prototype._addEdge.call(this,a,b,c,d,this._inEdges,this._outEdges)},g.prototype.delEdge=function(a){e.prototype._delEdge.call(this,a,this._inEdges,this._outEdges)},g.prototype._filterNodes=function(a){var b=[];return this.eachNode(function(c){a(c)&&b.push(c)}),b}},{"./BaseGraph":12,"./util":32,"cp-data":34}],16:[function(a,b,c){function g(){e.call(this),this._incidentEdges={}}var d=a("./util"),e=a("./BaseGraph"),f=a("cp-data").Set;b.exports=g,g.prototype=new e,g.prototype.constructor=g,g.prototype.isDirected=function(){return!1},g.prototype.neighbors=function(a){return this._strictGetNode(a),Object.keys(this._incidentEdges[a]).map(function(a){return this._nodes[a].id},this)},g.prototype.incidentEdges=function(a,b){return this._strictGetNode(a),arguments.length>1?(this._strictGetNode(b),b in this._incidentEdges[a]?this._incidentEdges[a][b].keys():[]):f.union(d.values(this._incidentEdges[a])).keys()},g.prototype.toString=function(){return"Graph "+JSON.stringify(this,null,2)},g.prototype.addNode=function(a,b){return a=e.prototype.addNode.call(this,a,b),this._incidentEdges[a]={},a},g.prototype.delNode=function(a){e.prototype.delNode.call(this,a),delete this._incidentEdges[a]},g.prototype.addEdge=function(a,b,c,d){return e.prototype._addEdge.call(this,a,b,c,d,this._incidentEdges,this._incidentEdges)},g.prototype.delEdge=function(a){e.prototype._delEdge.call(this,a,this._incidentEdges,this._incidentEdges)}},{"./BaseGraph":12,"./util":32,"cp-data":34}],17:[function(a,b,c){function e(a){function e(b,d){c.has(b)||(c.add(b),d.push(b),a.neighbors(b).forEach(function(a){e(a,d)}))}var b=[],c=new d;return a.nodes().forEach(function(a){var c=[];e(a,c),c.length>0&&b.push(c)}),b}var d=a("cp-data").Set;b.exports=e},{"cp-data":34}],18:[function(a,b,c){function e(a,b,c,e){function h(b){var d=a.incidentNodes(b),e=d[0]!==i?d[0]:d[1],h=f[e],k=c(b),l=j.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+k);l<h.distance&&(h.distance=l,h.predecessor=i,g.decrease(e,l))}var f={},g=new d;c=c||function(){return 1},e=e||(a.isDirected()?function(b){return a.outEdges(b)}:function(b){return a.incidentEdges(b)}),a.eachNode(function(a){var c=a===b?0:Number.POSITIVE_INFINITY;f[a]={distance:c},g.add(a,c)});var i,j;while(g.size
2
+ ()>0){i=g.removeMin(),j=f[i];if(j.distance===Number.POSITIVE_INFINITY)break;e(i).forEach(h)}return f}var d=a("cp-data").PriorityQueue;b.exports=e},{"cp-data":34}],19:[function(a,b,c){function e(a,b,c){var e={};return a.eachNode(function(f){e[f]=d(a,f,b,c)}),e}var d=a("./dijkstra");b.exports=e},{"./dijkstra":18}],20:[function(a,b,c){function e(a){return d(a).filter(function(a){return a.length>1})}var d=a("./tarjan");b.exports=e},{"./tarjan":26}],21:[function(a,b,c){function d(a,b,c){var d={},e=a.nodes();return b=b||function(){return 1},c=c||(a.isDirected()?function(b){return a.outEdges(b)}:function(b){return a.incidentEdges(b)}),e.forEach(function(f){d[f]={},d[f][f]={distance:0},e.forEach(function(a){f!==a&&(d[f][a]={distance:Number.POSITIVE_INFINITY})}),c(f).forEach(function(c){var e=a.incidentNodes(c),h=e[0]!==f?e[0]:e[1],i=b(c);i<d[f][h].distance&&(d[f][h]={distance:i,predecessor:f})})}),e.forEach(function(a){var b=d[a];e.forEach(function(c){var f=d[c];e.forEach(function(c){var d=f[a],e=b[c],g=f[c],h=d.distance+e.distance;h<g.distance&&(g.distance=h,g.predecessor=e.predecessor)})})}),d}b.exports=d},{}],22:[function(a,b,c){function e(a){try{d(a)}catch(b){if(b instanceof d.CycleException)return!1;throw b}return!0}var d=a("./topsort");b.exports=e},{"./topsort":27}],23:[function(a,b,c){function e(a,b,c){function f(b,d){if(e.has(b))throw new Error("The input graph is not a tree: "+a);e.add(b),a.neighbors(b).forEach(function(a){a!==d&&f(a,b)}),c(b)}var e=new d;if(a.isDirected())throw new Error("This function only works for undirected graphs");f(b)}var d=a("cp-data").Set;b.exports=e},{"cp-data":34}],24:[function(a,b,c){function e(a,b,c){function f(b,d){if(e.has(b))throw new Error("The input graph is not a tree: "+a);e.add(b),c(b),a.neighbors(b).forEach(function(a){a!==d&&f(a,b)})}var e=new d;if(a.isDirected())throw new Error("This function only works for undirected graphs");f(b)}var d=a("cp-data").Set;b.exports=e},{"cp-data":34}],25:[function(a,b,c){function f(a,b){function i(c){var d=a.incidentNodes(c),e=d[0]!==h?d[0]:d[1],i=g.priority(e);if(i!==undefined){var j=b(c);j<i&&(f[e]=h,g.decrease(e,j))}}var c=new d,f={},g=new e,h;if(a.order()===0)return c;a.eachNode(function(a){g.add(a,Number.POSITIVE_INFINITY),c.addNode(a)}),g.decrease(a.nodes()[0],0);var j=!1;while(g.size()>0){h=g.removeMin();if(h in f)c.addEdge(null,h,f[h]);else{if(j)throw new Error("Input graph is not connected: "+a);j=!0}a.incidentEdges(h).forEach(i)}return c}var d=a("../Graph"),e=a("cp-data").PriorityQueue;b.exports=f},{"../Graph":16,"cp-data":34}],26:[function(a,b,c){function d(a){function f(h){var i=d[h]={onStack:!0,lowlink:b,index:b++};c.push(h),a.successors(h).forEach(function(a){a in d?d[a].onStack&&(i.lowlink=Math.min(i.lowlink,d[a].index)):(f(a),i.lowlink=Math.min(i.lowlink,d[a].lowlink))});if(i.lowlink===i.index){var j=[],k;do k=c.pop(),d[k].onStack=!1,j.push(k);while(h!==k);e.push(j)}}if(!a.isDirected())throw new Error("tarjan can only be applied to a directed graph. Bad input: "+a);var b=0,c=[],d={},e=[];return a.nodes().forEach(function(a){a in d||f(a)}),e}b.exports=d},{}],27:[function(a,b,c){function d(a){function f(g){if(g in c)throw new e;g in b||(c[g]=!0,b[g]=!0,a.predecessors(g).forEach(function(a){f(a)}),delete c[g],d.push(g))}if(!a.isDirected())throw new Error("topsort can only be applied to a directed graph. Bad input: "+a);var b={},c={},d=[],g=a.sinks();if(a.order()!==0&&g.length===0)throw new e;return a.sinks().forEach(function(a){f(a)}),d}function e(){}b.exports=d,d.CycleException=e,e.prototype.toString=function(){return"Graph has at least one cycle"}},{}],28:[function(a,b,c){function e(a){function b(){a.call(this),this._parents={},this._children={},this._children[null]=new d}return b.prototype=new a,b.prototype.constructor=b,b.prototype.parent=function(a,b){this._strictGetNode(a);if(arguments.length<2)return this._parents[a];if(a===b)throw new Error("Cannot make "+a+" a parent of itself");b!==null&&this._strictGetNode(b),this._children[this._parents[a]].remove(a),this._parents[a]=b,this._children[b].add(a)},b.prototype.children=function(a){return a!==null&&this._strictGetNode(a),this._children[a].keys()},b.prototype.addNode=function(b,c){return b=a.prototype.addNode.call(this,b,c),this._parents[b]=null,this._children[b]=new d,this._children[null].add(b),b},b.prototype.delNode=function(b){var c=this.parent(b);return this._children[b].keys().forEach(function(a){this.parent(a,c)},this),this._children[c].remove(b),delete this._parents[b],delete this._children[b],a.prototype.delNode.call(this,b)},b.prototype.copy=function(){var b=a.prototype.copy.call(this);return this.nodes().forEach(function(a){b.parent(a,this.parent(a))},this),b},b.prototype.filterNodes=function(b){function f(a){var b=c.parent(a);return b===null||d.hasNode(b)?(e[a]=b,b):b in e?e[b]:f(b)}var c=this,d=a.prototype.filterNodes.call(this,b),e={};return d.eachNode(function(a){d.parent(a,f(a))}),d},b}var d=a("cp-data").Set;b.exports=e},{"cp-data":34}],29:[function(a,b,c){function h(a){return Object.prototype.toString.call(a).slice(8,-1)}var d=a("../Graph"),e=a("../Digraph"),f=a("../CGraph"),g=a("../CDigraph");c.decode=function(a,b,c){c=c||e;if(h(a)!=="Array")throw new Error("nodes is not an Array");if(h(b)!=="Array")throw new Error("edges is not an Array");if(typeof c=="string")switch(c){case"graph":c=d;break;case"digraph":c=e;break;case"cgraph":c=f;break;case"cdigraph":c=g;break;default:throw new Error("Unrecognized graph type: "+c)}var i=new c;return a.forEach(function(a){i.addNode(a.id,a.value)}),i.parent&&a.forEach(function(a){a.children&&a.children.forEach(function(b){i.parent(b,a.id)})}),b.forEach(function(a){i.addEdge(a.id,a.u,a.v,a.value)}),i},c.encode=function(a){var b=[],c=[];a.eachNode(function(c,d){var e={id:c,value:d};if(a.children){var f=a.children(c);f.length&&(e.children=f)}b.push(e)}),a.eachEdge(function(a,b,d,e){c.push({id:a,u:b,v:d,value:e})});var h;if(a instanceof g)h="cdigraph";else if(a instanceof f)h="cgraph";else if(a instanceof e)h="digraph";else if(a instanceof d)h="graph";else throw new Error("Couldn't determine type of graph: "+a);return{nodes:b,edges:c,type:h}}},{"../CDigraph":13,"../CGraph":14,"../Digraph":15,"../Graph":16}],30:[function(a,b,c){var d=a("cp-data").Set;c.all=function(){return function(){return!0}},c.nodesFromList=function(a){var b=new d(a);return function(a){return b.has(a)}}},{"cp-data":34}],31:[function(a,b,c){var d=a("./Graph"),e=a("./Digraph");d.prototype.toDigraph=d.prototype.asDirected=function(){var a=new e;return this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(null,c,d,e),a.addEdge(null,d,c,e)}),a},e.prototype.toGraph=e.prototype.asUndirected=function(){var a=new d;return this.eachNode(function(b,c){a.addNode(b,c)}),this.eachEdge(function(b,c,d,e){a.addEdge(b,c,d,e)}),a}},{"./Digraph":15,"./Graph":16}],32:[function(a,b,c){c.values=function(a){var b=Object.keys(a),c=b.length,d=new Array(c),e;for(e=0;e<c;++e)d[e]=a[b[e]];return d}},{}],33:[function(a,b,c){b.exports="0.7.4"},{}],34:[function(a,b,c){c.Set=a("./lib/Set"),c.PriorityQueue=a("./lib/PriorityQueue"),c.version=a("./lib/version")},{"./lib/PriorityQueue":35,"./lib/Set":36,"./lib/version":38}],35:[function(a,b,c){function d(){this._arr=[],this._keyIndices={}}b.exports=d,d.prototype.size=function(){return this._arr.length},d.prototype.keys=function(){return this._arr.map(function(a){return a.key})},d.prototype.has=function(a){return a in this._keyIndices},d.prototype.priority=function(a){var b=this._keyIndices[a];if(b!==undefined)return this._arr[b].priority},d.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},d.prototype.add=function(a,b){var c=this._keyIndices;if(a in c)return!1;var d=this._arr,e=d.length;return c[a]=e,d.push({key:a,priority:b}),this._decrease(e),!0},d.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var a=this._arr.pop();return delete this._keyIndices[a.key],this._heapify(0),a.key},d.prototype.decrease=function(a,b){var c=this._keyIndices[a];if(b>this._arr[c].priority)throw new Error("New priority is greater than current priority. Key: "+a+" Old: "+this._arr[c].priority+" New: "+b);this._arr[c].priority=b,this._decrease(c)},d.prototype._heapify=function(a){var b=this._arr,c=2*a,d=c+1,e=a;c<b.length&&(e=b[c].priority<b[e].priority?c:e,d<b.length&&(e=b[d].priority<b[e].priority?d:e),e!==a&&(this._swap(a,e),this._heapify(e)))},d.prototype._decrease=function(a){var b=this._arr,c=b[a].priority,d;while(a!==0){d=a>>1;if(b[d].priority<c)break;this._swap(a,d),a=d}},d.prototype._swap=function(a,b){var c=this._arr,d=this._keyIndices,e=c[a],f=c[b];c[a]=f,c[b]=e,d[f.key]=a,d[e.key]=b}},{}],36:[function(a,b,c){function e(a){this._size=0,this._keys={};if(a)for(var b=0,c=a.length;b<c;++b)this.add(a[b])}function f(a){var b=Object.keys(a),c=b.length,d=new Array(c),e;for(e=0;e<c;++e)d[e]=a[b[e]];return d}var d=a("./util");b.exports=e,e.intersect=function(a){if(a.length===0)return new e;var b=new e(d.isArray(a[0])?a[0]:a[0].keys());for(var c=1,f=a.length;c<f;++c){var g=b.keys(),h=d.isArray(a[c])?new e(a[c]):a[c];for(var i=0,j=g.length;i<j;++i){var k=g[i];h.has(k)||b.remove(k)}}return b},e.union=function(a){var b=d.reduce(a,function(a,b){return a+(b.size?b.size():b.length)},0),c=new Array(b),f=0;for(var g=0,h=a.length;g<h;++g){var i=a[g],j=d.isArray(i)?i:i.keys();for(var k=0,l=j.length;k<l;++k)c[f++]=j[k]}return new e(c)},e.prototype.size=function(){return this._size},e.prototype.keys=function(){return f(this._keys)},e.prototype.has=function(a){return a in this._keys},e.prototype.add=function(a){return a in this._keys?!1:(this._keys[a]=a,++this._size,!0)},e.prototype.remove=function(a){return a in this._keys?(delete this._keys[a],--this._size,!0):!1}},{"./util":37}],37:[function(a,b,c){Array.isArray?c.isArray=Array.isArray:c.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"},"function"!=typeof Array.prototype.reduce?c.reduce=function(a,b,c){"use strict";if(null===a||"undefined"==typeof a)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var d,e,f=a.length>>>0,g=!1;1<arguments.length&&(e=c,g=!0);for(d=0;f>d;++d)a.hasOwnProperty(d)&&(g?e=b(e,a[d],d,a):(e=a[d],g=!0));if(!g)throw new TypeError("Reduce of empty array with no initial value");return e}:c.reduce=function(a,b,c){return a.reduce(b,c)}},{}],38:[function(a,b,c){b.exports="1.1.3"},{}]},{},[1]);
@@ -0,0 +1,117 @@
1
+ <style type="text/css">
2
+ <!--
3
+ body {
4
+ font-size:70%;
5
+ padding:0;
6
+ margin:5px;
7
+ margin-right:0px;
8
+ margin-left:0px;
9
+ background: #ffffff;
10
+ }
11
+ ul {
12
+ margin-left:0px;
13
+ margin-top:0px;
14
+ margin-bottom:0px;
15
+ padding-left:0px;
16
+ list-style-type:none;
17
+ }
18
+ li {
19
+ margin-left:11px;
20
+ padding:0px;
21
+ white-space:nowrap;
22
+ border-top:1px solid #cccccc;
23
+ border-left:1px solid #cccccc;
24
+ border-bottom:none;
25
+ }
26
+ .thread {
27
+ margin-left:11px;
28
+ background:#708090;
29
+ padding-top:3px;
30
+ padding-left:12px;
31
+ padding-bottom:2px;
32
+ border-left:1px solid #CCCCCC;
33
+ border-top:1px solid #CCCCCC;
34
+ font-weight:bold;
35
+ }
36
+ .hidden {
37
+ display:none;
38
+ width:0px;
39
+ height:0px;
40
+ margin:0px;
41
+ padding:0px;
42
+ border-style:none;
43
+ }
44
+ .color01 { background:#adbdeb }
45
+ .color05 { background:#9daddb }
46
+ .color0 { background:#8d9dcb }
47
+ .color1 { background:#89bccb }
48
+ .color2 { background:#56e3e7 }
49
+ .color3 { background:#32cd70 }
50
+ .color4 { background:#a3d53c }
51
+ .color5 { background:#c4cb34 }
52
+ .color6 { background:#dcb66d }
53
+ .color7 { background:#cda59e }
54
+ .color8 { background:#be9d9c }
55
+ .color9 { background:#cf947a }
56
+ #commands {
57
+ font-size:10pt;
58
+ padding:10px;
59
+ margin-left:11px;
60
+ margin-bottom:0px;
61
+ margin-top:0px;
62
+ background:#708090;
63
+ border-top:1px solid #cccccc;
64
+ border-left:1px solid #cccccc;
65
+ border-bottom:none;
66
+ }
67
+ #titlebar {
68
+ font-size:10pt;
69
+ padding:10px;
70
+ margin-left:11px;
71
+ margin-bottom:0px;
72
+ margin-top:10px;
73
+ background:#8090a0;
74
+ border-top:1px solid #cccccc;
75
+ border-left:1px solid #cccccc;
76
+ border-bottom:none;
77
+ }
78
+ #help {
79
+ font-size:10pt;
80
+ padding:10px;
81
+ margin-left:11px;
82
+ margin-bottom:0px;
83
+ margin-top:0px;
84
+ background:#8090a0;
85
+ display:none;
86
+ border-top:1px solid #cccccc;
87
+ border-left:1px solid #cccccc;
88
+ border-bottom:none;
89
+ }
90
+ #sentinel {
91
+ height: 400px;
92
+ margin-left:11px;
93
+ background:#8090a0;
94
+ border-top:1px solid #cccccc;
95
+ border-left:1px solid #cccccc;
96
+ border-bottom:none;
97
+ }
98
+ input { margin-left:10px; }
99
+
100
+ .toggle {
101
+ background: url(/oneapm/assets/images/call_stack_printer.png) no-repeat left center;
102
+ float:left;
103
+ width:9px;
104
+ height:9px;
105
+ margin:2px 1px 1px 1px;
106
+ }
107
+
108
+ .toggle.minus {
109
+ background-position: -9px 0;
110
+ }
111
+
112
+ .toggle.plus {
113
+ background-position: -18px 0;
114
+ }
115
+
116
+ -->
117
+ </style>
@@ -147,3 +147,20 @@ span.application_title {
147
147
  border-radius: 2px;
148
148
  line-height: 20px;
149
149
  }
150
+
151
+ svg {
152
+ overflow: hidden;
153
+ }
154
+ .node rect {
155
+ stroke: #333;
156
+ stroke-width: 1.5px;
157
+ fill: #fff;
158
+ }
159
+ .edgeLabel rect {
160
+ fill: #fff;
161
+ }
162
+ .edgePath {
163
+ stroke: #333;
164
+ stroke-width: 1.5px;
165
+ fill: none;
166
+ }
@@ -9,6 +9,7 @@
9
9
  <link rel="stylesheet" href="/oneapm/assets/stylesheets/bootstrap.min.css">
10
10
  <link rel="stylesheet" href="/oneapm/assets/stylesheets/c3.css" media="screen" type="text/css" />
11
11
  <link rel="stylesheet" href="/oneapm/assets/stylesheets/style.css" media="screen" type="text/css" />
12
+ <link rel="stylesheet" href="/oneapm/assets/stylesheets/call_stack_printer.css" media="screen" type="text/css" />
12
13
  </head>
13
14
  <body>
14
15
  <div class="container-fluid header">
@@ -30,15 +30,15 @@
30
30
 
31
31
  <div class="row">
32
32
  <div class="col-lg-12">
33
- <% if @sample.profile %>
34
- <%= profile_table(@sample, @profile_options) %>
35
- <% else %>
36
33
  <div class="row">
37
34
  <div class="col-lg-offset-3 col-lg-6">
38
35
  <div class="btn-group btn-group-justified" style="padding-bottom: 20px;">
39
36
  <a href="show_sample_summary?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_summary">概 览</a>
40
37
  <a href="show_sample_detail?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_detail">详 细</a>
41
38
  <a href="show_sample_sql?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_sql">数据库</a>
39
+ <% if @sample.profile %>
40
+ <a href="show_sample_profile?id=<%= @sample.sample_id %>&t=p" class="btn btn-primary show_sample_profile">性能剖析</a>
41
+ <% end%>
42
42
  </div>
43
43
  </div>
44
44
  </div>
@@ -49,13 +49,11 @@
49
49
  %w[show_sample_summary show_sample_sql show_sample_detail].select do |p|
50
50
  current_partial = p if @req.path.include?(p)
51
51
  end
52
-
53
52
  options = {:align => 'center', :id => current_partial}
54
53
  %>
55
54
  <%= content_tag('div', render(:partial => current_partial), options) %>
56
55
  <script type="text/javascript">
57
56
  $(".<%= current_partial %>").addClass('active');
58
57
  </script>
59
- <% end %>
60
58
  </div>
61
59
  </div>
@@ -0,0 +1,528 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>OneAPM 开发模式</title>
6
+ <link rel="stylesheet" href="/oneapm/assets/stylesheets/bootstrap.min.css">
7
+ <link rel="stylesheet" href="/oneapm/assets/stylesheets/c3.css" media="screen" type="text/css" />
8
+ <link rel="stylesheet" href="/oneapm/assets/stylesheets/style.css" media="screen" type="text/css" />
9
+ <link rel="stylesheet" href="/oneapm/assets/stylesheets/call_stack_printer.css" media="screen" type="text/css" />
10
+ <script type="text/javascript" src="/oneapm/assets/javascript/jquery.min.js"></script>
11
+ <script type="text/javascript" src="/oneapm/assets/javascript/d3.min.js"></script>
12
+ <script type="text/javascript" src="/oneapm/assets/javascript/c3.min.js"></script>
13
+ <script type="text/javascript" src="/oneapm/assets/javascript/graphlib-dot.min.js"></script>
14
+ <script type="text/javascript" src="/oneapm/assets/javascript/dagre-d3.min.js"></script>
15
+
16
+ <script type="text/javascript">
17
+
18
+ function rootNode() {
19
+ return currentThread;
20
+ }
21
+
22
+ function showUL(node, show) {
23
+ var lis = node.childNodes;
24
+ var l = lis.length;
25
+ for (var i=0; i < l ; i++ ) {
26
+ toggle(lis[i], show);
27
+ }
28
+ }
29
+
30
+ function findUlChild(li){
31
+ var ul = li.childNodes[2];
32
+ while (ul && ul.nodeName != "UL") {
33
+ ul = ul.nextSibling;
34
+ }
35
+ return ul;
36
+ }
37
+
38
+ function isLeafNode(li) {
39
+ var img = li.firstChild;
40
+ return (img.className.indexOf('empty') > -1);
41
+ }
42
+
43
+ function toggle(li, show) {
44
+ if (isLeafNode(li))
45
+ return;
46
+
47
+ var img = li.firstChild;
48
+ img.className = 'toggle ';
49
+ img.className += show ? 'minus' : 'plus';
50
+
51
+ var ul = findUlChild(li);
52
+ if (ul) {
53
+ ul.style.display = show ? 'block' : 'none';
54
+ showUL(ul, true);
55
+ }
56
+ }
57
+
58
+ function toggleLI(li) {
59
+ var img = li.firstChild;
60
+ if (img.className.indexOf("minus")>-1)
61
+ toggle(li, false);
62
+ else {
63
+ if (img.className.indexOf("plus")>-1)
64
+ toggle(li, true);
65
+ }
66
+ }
67
+
68
+ function aboveThreshold(text, threshold) {
69
+ var match = text.match(/\d+[.,]\d+/);
70
+ return (match && parseFloat(match[0].replace(/,/, '.'))>=threshold);
71
+ }
72
+
73
+ function setThresholdLI(li, threshold) {
74
+ var img = li.firstChild;
75
+ var text = img.nextSibling;
76
+ var ul = findUlChild(li);
77
+
78
+ var visible = aboveThreshold(text.nodeValue, threshold) ? 1 : 0;
79
+
80
+ var count = 0;
81
+ if (ul) {
82
+ count = setThresholdUL(ul, threshold);
83
+ }
84
+ if (count>0) {
85
+ img.className = 'toggle minus';
86
+ }
87
+ else {
88
+ img.className = 'toggle empty';
89
+ }
90
+ if (visible) {
91
+ li.style.display = 'block'
92
+ }
93
+ else {
94
+ li.style.display = 'none'
95
+ }
96
+ return visible;
97
+ }
98
+
99
+ function setThresholdUL(node, threshold) {
100
+ var lis = node.childNodes;
101
+ var l = lis.length;
102
+
103
+ var count = 0;
104
+ for ( var i = 0; i < l ; i++ ) {
105
+ count = count + setThresholdLI(lis[i], threshold);
106
+ }
107
+
108
+ var visible = (count > 0) ? 1 : 0;
109
+ if (visible) {
110
+ node.style.display = 'block';
111
+ }
112
+ else {
113
+ node.style.display = 'none';
114
+ }
115
+ return visible;
116
+ }
117
+
118
+ function toggleChildren(img, event) {
119
+ event.cancelBubble=true;
120
+ if (img.className.indexOf('empty') > -1)
121
+ return;
122
+
123
+ var minus = (img.className.indexOf('minus') > -1);
124
+
125
+ if (minus) {
126
+ img.className = 'toggle plus';
127
+ }
128
+ else
129
+ img.className = 'toggle minus';
130
+
131
+ var li = img.parentNode;
132
+ var ul = findUlChild(li);
133
+ if (ul) {
134
+ if (minus)
135
+ ul.style.display = 'none';
136
+ else
137
+ ul.style.display = 'block';
138
+ }
139
+ if (minus)
140
+ moveSelectionIfNecessary(li);
141
+ }
142
+
143
+ function showChildren(li) {
144
+ var img = li.firstChild;
145
+ if (img.className.indexOf('empty') > -1)
146
+ return;
147
+ img.className = 'toggle minus';
148
+
149
+ var ul = findUlChild(li);
150
+ if (ul) {
151
+ ul.style.display = 'block';
152
+ }
153
+ }
154
+
155
+ function setThreshold() {
156
+ var tv = document.getElementById("threshold").value;
157
+ if (tv.match(/[0-9]+([.,][0-9]+)?/)) {
158
+ var f = parseFloat(tv.replace(/,/, '.'));
159
+ var threads = document.getElementsByName("thread");
160
+ var l = threads.length;
161
+ for ( var i = 0; i < l ; i++ ) {
162
+ setThresholdUL(threads[i], f);
163
+ }
164
+ var p = selectedNode;
165
+ while (p && p.style.display=='none')
166
+ p=p.parentNode.parentNode;
167
+ if (p && p.nodeName=="LI")
168
+ selectNode(p);
169
+ }
170
+ else {
171
+ alert("Please specify a decimal number as threshold value!");
172
+ }
173
+ }
174
+
175
+ function expandAll(event) {
176
+ toggleAll(event, true);
177
+ }
178
+
179
+ function collapseAll(event) {
180
+ toggleAll(event, false);
181
+ selectNode(rootNode(), null);
182
+ }
183
+
184
+ function toggleAll(event, show) {
185
+ event.cancelBubble=true;
186
+ var threads = document.getElementsByName("thread");
187
+ var l = threads.length;
188
+ for ( var i = 0; i < l ; i++ ) {
189
+ showUL(threads[i], show);
190
+ }
191
+ }
192
+
193
+ function toggleHelp(node) {
194
+ var help = document.getElementById("help");
195
+ if (node.value == "Show Help") {
196
+ node.value = "Hide Help";
197
+ help.style.display = 'block';
198
+ }
199
+ else {
200
+ node.value = "Show Help";
201
+ help.style.display = 'none';
202
+ }
203
+ }
204
+
205
+ var selectedNode = null;
206
+ var selectedColor = null;
207
+ var selectedThread = null;
208
+
209
+ function descendentOf(a,b){
210
+ while (a!=b && b!=null)
211
+ b=b.parentNode;
212
+ return (a==b);
213
+ }
214
+
215
+ function moveSelectionIfNecessary(node){
216
+ if (descendentOf(node, selectedNode))
217
+ selectNode(node, null);
218
+ }
219
+
220
+ function selectNode(node, event) {
221
+ if (event) {
222
+ event.cancelBubble = true;
223
+ thread = findThread(node);
224
+ selectThread(thread);
225
+ }
226
+ if (selectedNode) {
227
+ selectedNode.style.background = selectedColor;
228
+ }
229
+ selectedNode = node;
230
+ selectedColor = node.style.background;
231
+ selectedNode.style.background = "red";
232
+ selectedNode.scrollIntoView();
233
+ window.scrollBy(0,-400);
234
+ }
235
+
236
+ function moveUp(){
237
+ move(selectedNode.previousSibling);
238
+ }
239
+
240
+ function moveDown(){
241
+ move(selectedNode.nextSibling);
242
+ }
243
+
244
+ function move(p) {
245
+ while (p && p.style.display == 'none')
246
+ p = p.nextSibling;
247
+ if (p && p.nodeName == "LI") {
248
+ selectNode(p, null);
249
+ }
250
+ }
251
+
252
+ function moveLeft(){
253
+ var p = selectedNode.parentNode.parentNode;
254
+ if (p && p.nodeName=="LI") {
255
+ selectNode(p, null);
256
+ }
257
+ }
258
+
259
+ function moveRight(){
260
+ if (!isLeafNode(selectedNode)) {
261
+ showChildren(selectedNode);
262
+ var ul = findUlChild(selectedNode);
263
+ if (ul) {
264
+ selectNode(ul.firstChild, null);
265
+ }
266
+ }
267
+ }
268
+
269
+ function moveForward(){
270
+ if (isLeafNode(selectedNode)) {
271
+ var p = selectedNode;
272
+ while ((p.nextSibling == null || p.nextSibling.style.display=='none') && p.nodeName=="LI") {
273
+ p = p.parentNode.parentNode;
274
+ }
275
+ if (p.nodeName=="LI")
276
+ selectNode(p.nextSibling, null);
277
+ }
278
+ else {
279
+ moveRight();
280
+ }
281
+ }
282
+
283
+ function isExpandedNode(li){
284
+ var img = li.firstChild;
285
+ return(img.className.indexOf('minus')>-1);
286
+ }
287
+
288
+ function moveBackward(){
289
+ var p = selectedNode;
290
+ var q = p.previousSibling;
291
+ while (q != null && q.style.display=='none')
292
+ q = q.previousSibling;
293
+ if (q == null) {
294
+ p = p.parentNode.parentNode;
295
+ } else {
296
+ while (!isLeafNode(q) && isExpandedNode(q)) {
297
+ q = findUlChild(q).lastChild;
298
+ while (q.style.display=='none')
299
+ q = q.previousSibling;
300
+ }
301
+ p = q;
302
+ }
303
+ if (p.nodeName=="LI")
304
+ selectNode(p, null);
305
+ }
306
+
307
+ function moveHome() {
308
+ selectNode(currentThread);
309
+ }
310
+
311
+ var currentThreadIndex = null;
312
+
313
+ function findThread(node){
314
+ while (node && !node.parentNode.nodeName.match(/BODY|DIV/g)) {
315
+ node = node.parentNode;
316
+ }
317
+ return node.firstChild;
318
+ }
319
+
320
+ function selectThread(node){
321
+ var threads = document.getElementsByName("thread");
322
+ currentThread = node;
323
+ for (var i=0; i<threads.length; i++) {
324
+ if (threads[i]==currentThread.parentNode)
325
+ currentThreadIndex = i;
326
+ }
327
+ }
328
+
329
+ function nextThread(){
330
+ var threads = document.getElementsByName("thread");
331
+ if (currentThreadIndex==threads.length-1)
332
+ currentThreadIndex = 0;
333
+ else
334
+ currentThreadIndex += 1
335
+ currentThread = threads[currentThreadIndex].firstChild;
336
+ selectNode(currentThread, null);
337
+ }
338
+
339
+ function previousThread(){
340
+ var threads = document.getElementsByName("thread");
341
+ if (currentThreadIndex==0)
342
+ currentThreadIndex = threads.length-1;
343
+ else
344
+ currentThreadIndex -= 1
345
+ currentThread = threads[currentThreadIndex].firstChild;
346
+ selectNode(currentThread, null);
347
+ }
348
+
349
+ function switchThread(node, event){
350
+ event.cancelBubble = true;
351
+ selectThread(node.nextSibling.firstChild);
352
+ selectNode(currentThread, null);
353
+ }
354
+
355
+ function handleKeyEvent(event){
356
+ var code = event.charCode ? event.charCode : event.keyCode;
357
+ var str = String.fromCharCode(code);
358
+ switch (str) {
359
+ case "a": moveLeft(); break;
360
+ case "s": moveDown(); break;
361
+ case "d": moveRight(); break;
362
+ case "w": moveUp(); break;
363
+ case "f": moveForward(); break;
364
+ case "b": moveBackward(); break;
365
+ case "x": toggleChildren(selectedNode.firstChild, event); break;
366
+ case "*": toggleLI(selectedNode); break;
367
+ case "n": nextThread(); break;
368
+ case "h": moveHome(); break;
369
+ case "p": previousThread(); break;
370
+ }
371
+ }
372
+ document.onkeypress=function(event){ handleKeyEvent(event) };
373
+
374
+ window.onload=function(){
375
+ var outer = d3.select("svg")
376
+ .attr({ width: 960, height: 960, "pointer-events": "all" });
377
+
378
+ outer.attr({ width: "100%", height: "100%" })
379
+ .call(d3.behavior.zoom().on("zoom", redraw));
380
+
381
+ var vis = outer.select('g')
382
+ .attr('transform', 'translate(250,250) scale(0.3)');
383
+
384
+ function redraw() {
385
+ vis.attr("transform", "translate(" + d3.event.translate + ")" + " scale(" + d3.event.scale + ")");
386
+ }
387
+
388
+ // Parse the DOT syntax into a graphlib object.
389
+ var g = graphlibDot.parse(
390
+ <%= profile_table(@sample, @profile_options) if dot?%>
391
+ )
392
+
393
+ // Render the graphlib object using d3.
394
+ var renderer = new dagreD3.Renderer();
395
+
396
+ renderer.run(g, d3.select("svg g"));
397
+
398
+
399
+ // Optional - resize the SVG element based on the contents.
400
+ var svg = document.querySelector('#graphContainer');
401
+ var bbox = svg.getBBox();
402
+ svg.style.width = bbox.width + 40.0 + "px";
403
+ svg.style.height = bbox.height + 40.0 + "px";
404
+
405
+
406
+ var images = document.querySelectorAll(".toggle");
407
+ for (var i=0; i<images.length; i++) {
408
+ var img = images[i];
409
+ img.onclick = function(event){ toggleChildren(this, event); return false; };
410
+ }
411
+ var divs = document.getElementsByTagName("div");
412
+ for (i=0; i<divs.length; i++) {
413
+ var div = divs[i];
414
+ if (div.className == "thread")
415
+ div.onclick = function(event){ switchThread(this, event) };
416
+ }
417
+ var lis = document.getElementsByTagName("li");
418
+ for (var i=0; i<lis.length; i++) {
419
+ lis[i].onclick = function(event){ selectNode(this, event); };
420
+ }
421
+ var threads = document.getElementsByName("thread");;
422
+ currentThreadIndex = 0;
423
+ currentThread = threads[0].firstChild;
424
+ selectNode(currentThread, null);
425
+
426
+ };
427
+
428
+ </script>
429
+ </head>
430
+ <body>
431
+ <div class="container-fluid header">
432
+ <div class="row">
433
+ <div class="col-lg-6">
434
+ <div class="pull-left">
435
+ <a href="/oneapm">
436
+ <img src="/oneapm/assets/images/oneapm_logo.png" alt="OneAPM" />
437
+ <span class="application_title">开发模式</span>
438
+ </a>
439
+ </div>
440
+ </div>
441
+ <div class="col-lg-6">
442
+ <div class="pull-right">
443
+ 在生产环境下监控您应用程序的性能。<a href="http://www.oneapm.com/ai/ruby.html" class="goto-oneapm-ruby">点击这里查看如何设置</a>
444
+ </div>
445
+ </div>
446
+ </div>
447
+ </div>
448
+ <div class="container-fluid main-container">
449
+
450
+ <div class="row">
451
+ <div class="col-lg-12 code">
452
+ <div class="current-url">
453
+ <h3><%= @sample.params[:uri]%></h3>
454
+ </div>
455
+ </div>
456
+ </div>
457
+ <div class="row">
458
+ <div class="col-lg-12">
459
+ <table class="table sample_table code current-request">
460
+ <tr>
461
+ <td>
462
+ <%= @sample_controller_name%>
463
+ </td>
464
+ <td>
465
+ <%= format_timestamp(Time.at(@sample.start_time)) %>
466
+ </td>
467
+ <td>
468
+ <%= colorize(@sample.duration, 1, 2) %> ms
469
+ </td>
470
+ <td>
471
+ CPU:<%= to_ms(@sample.params[:cpu_time]) if @sample.params[:cpu_time] %> ms
472
+ </td>
473
+ </tr>
474
+ </table>
475
+ </div>
476
+ </div>
477
+
478
+ <div class="row">
479
+ <div class="col-lg-12">
480
+ <div class="row">
481
+ <div class="col-lg-offset-3 col-lg-6">
482
+ <div class="btn-group btn-group-justified" style="padding-bottom: 20px;">
483
+ <a href="show_sample_summary?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_summary">概 览</a>
484
+ <a href="show_sample_detail?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_detail">详 细</a>
485
+ <a href="show_sample_sql?id=<%= @sample.sample_id %>" class="btn btn-primary show_sample_sql">数据库</a>
486
+ <% if @sample.profile %>
487
+ <a href="show_sample_profile?id=<%= @sample.sample_id %>&t=p" class="btn btn-primary show_sample_profile">性能剖析</a>
488
+ <% end%>
489
+ </div>
490
+ </div>
491
+ </div>
492
+
493
+ <div class="row">
494
+ <div class="col-lg-12">
495
+ <span>
496
+ <a href="show_sample_profile?id=<%= @sample.sample_id %>">调用堆栈</a>&nbsp;&nbsp;
497
+ <a href="show_sample_profile?id=<%= @sample.sample_id %>&t=dot">调用跟踪图</a>
498
+ </span>
499
+ <%= profile_table(@sample, @profile_options) unless dot?%>
500
+ <svg id="graphContainer">
501
+ <g/>
502
+ </svg>
503
+ </div>
504
+ </div>
505
+ </div>
506
+ </div>
507
+ <div class="container-fluid footer">
508
+ <div class="row">
509
+ <div class="col-lg-6">
510
+ <p>
511
+ 在生产环境下监控您应用程序的性能。<a href="http://www.oneapm.com/ai/ruby.html">点击这里查看如何设置
512
+ </p>
513
+ <p>
514
+ &copy; 2008 - <%= Time.now.strftime('%Y') %> OneAPM. All rights reserved.
515
+ </p>
516
+ </div>
517
+ </div>
518
+ </div>
519
+ </body>
520
+
521
+
522
+
523
+
524
+
525
+
526
+
527
+
528
+
@@ -5,11 +5,11 @@ module OneApm
5
5
 
6
6
  MAJOR = 1
7
7
  MINOR = 3
8
- TINY = 1
9
-
8
+ TINY = 2
9
+ TAG = 'rc1'
10
10
 
11
11
 
12
- STRING = [MAJOR, MINOR, TINY].compact.join('.')
12
+ STRING = [MAJOR, MINOR, TINY, TAG].compact.join('.')
13
13
 
14
14
  end
15
15
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oneapm_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.3.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - oneapm
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-04 00:00:00.000000000 Z
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -362,6 +362,7 @@ files:
362
362
  - lib/one_apm/inst/rails4/active_record_subscriber.rb
363
363
  - lib/one_apm/inst/rails4/errors.rb
364
364
  - lib/one_apm/inst/rails_middleware.rb
365
+ - lib/one_apm/inst/rubyprof.rb
365
366
  - lib/one_apm/inst/support/evented_subscriber.rb
366
367
  - lib/one_apm/inst/support/ignore_actions.rb
367
368
  - lib/one_apm/inst/support/queue_time.rb
@@ -395,6 +396,7 @@ files:
395
396
  - lib/one_apm/rack/developer_mode/views/oneapm/_summary_table.html.erb
396
397
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/arrow-close.png
397
398
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/arrow-open.png
399
+ - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/call_stack_printer.png
398
400
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/close_left.png
399
401
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/icon.png
400
402
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/loading-0.gif
@@ -402,12 +404,15 @@ files:
402
404
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/images/oneapm_logo.png
403
405
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/c3.min.js
404
406
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/d3.min.js
407
+ - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/dagre-d3.min.js
405
408
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/functions.js
409
+ - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/graphlib-dot.min.js
406
410
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/jquery.min.js
407
411
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/layer.js
408
412
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/javascript/transaction_sample.js
409
413
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/bootstrap.min.css
410
414
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/c3.css
415
+ - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/call_stack_printer.css
411
416
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/layer.css
412
417
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/menus.css
413
418
  - lib/one_apm/rack/developer_mode/views/oneapm/assets/stylesheets/style.css
@@ -416,6 +421,7 @@ files:
416
421
  - lib/one_apm/rack/developer_mode/views/oneapm/layout.html.erb
417
422
  - lib/one_apm/rack/developer_mode/views/oneapm/sample_not_found.html.erb
418
423
  - lib/one_apm/rack/developer_mode/views/oneapm/show_sample.html.erb
424
+ - lib/one_apm/rack/developer_mode/views/oneapm/show_sample_profile.html.erb
419
425
  - lib/one_apm/rack/developer_mode/views/oneapm/slide.tmpl
420
426
  - lib/one_apm/rack/developer_mode/views/oneapm/threads.html.erb
421
427
  - lib/one_apm/rack/middleware_base.rb