1
0
mirror of https://github.com/yldio/copilot.git synced 2024-12-01 07:30:07 +02:00

Spikes of d3 and sigma.js

This commit is contained in:
Tom Gallacher 2016-11-04 16:46:06 +00:00
parent f09acb1738
commit 5040fffaba
29 changed files with 24406 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# D3 graph layouts
D3 v4, has a nice force directed graph set of features, that allows you to implement features in the graph with ease. By just manipulating the nodes using svg attributes and css.
This with the addition that D3 is a very well respected and widely used toolkit, makes finding documentation and developer speed a breeze.
It does seem to slow down on larger nodes, but this is mainly due to the built in force directed animation, disabling this, or computing this in a web-worker can speed up things considerably.
As a developer I found my self more productive with the API that d3 exposes, and was able to accomplish more in the same time as other frameworks.
![screenshot from 2016-11-04 16-48-29](https://cloud.githubusercontent.com/assets/524382/20059671/5ab66080-a4ef-11e6-94d6-d09bbaa9a76a.png)

View File

@ -0,0 +1,147 @@
<!DOCTYPE html>
<meta charset='utf-8'>
<style>
.links line {
stroke: #343434;
stroke-opacity: 1;
}
.exclamation {
font-family: LibreFranklin;
font-size: 16px;
font-weight: bold;
font-style: normal;
font-stretch: normal;
text-align: center;
color: #d75148;
}
</style>
<svg width='960' height='600'></svg>
<script src='https://d3js.org/d3.v4.min.js'></script>
<script>
var svg = d3.select('svg'),
width = +svg.attr('width'),
height = +svg.attr('height');
var color = d3.scaleOrdinal(d3.schemeCategory20);
var simulation = d3.forceSimulation()
.force('link', d3.forceLink().distance(() => 200).id(function(d) { return d.id; }))
.force('charge', d3.forceManyBody())
.force('center', d3.forceCenter(width / 2, height / 2));
d3.json('services.json', function(error, graph) {
if (error) throw error;
var link = svg.append('g')
.attr('class', 'links')
.selectAll('line')
.data(graph.links)
.enter().append('line')
.attr('stroke-width', '2px')
var node = svg.selectAll('.node')
.data(graph.nodes)
.enter()
.append('g')
.attr('class', 'node_group');
// Info Box
node.append('rect')
.attr('class', 'node_info')
.attr('stroke', '#bc3e35')
.attr('stroke-width', '1px')
.attr('fill', '#d6534a')
.attr('height', '48px')
.attr('width', '48px')
.attr('rx', '4')
.attr('ry', '4')
// Box where text will live
node.append('rect')
.attr('class', 'node')
.attr('x', '48')
.attr('stroke', '#343434')
.attr('stroke-width', '1px')
.attr('fill', '#464646')
.attr('height', '48px')
.attr('width', '112px')
.attr('rx', '4')
.attr('ry', '4')
node.append('circle')
.attr('class', 'alert')
.attr('cx', '24')
.attr('cy', '24')
.attr('stroke-width', '0px')
.attr('fill', '#fff')
.attr('r', '9px')
node.append('text')
.attr('class', 'exclamation')
.attr('x', '24')
.attr('y', '30')
.attr('text-anchor', 'middle')
.attr('fill', '#d75148')
.text('!')
node.append('text')
.attr('class', 'info_text')
.attr('x', '100')
.attr('y', '30')
.attr('text-anchor', 'middle')
.attr('fill', '#fff')
.text(d => d.id)
node.call(d3.drag()
.on('start', dragstarted)
.on('drag', dragged)
.on('end', dragended));
node.append('title')
.text(function(d) { return d.id; });
simulation
.nodes(graph.nodes)
.on('tick', ticked);
simulation.force('link')
.links(graph.links);
function ticked() {
link
.attr('x1', function(d) { return d.source.x + 80; })
.attr('y1', function(d) { return d.source.y + 24; })
.attr('x2', function(d) { return d.target.x + 80; })
.attr('y2', function(d) { return d.target.y + 24; });
node
.attr('cx', function(d) { return d.x; })
.attr('cy', function(d) { return d.y; });
svg.selectAll(".node_group")
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });
}
});
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
</script>

View File

@ -0,0 +1,15 @@
{
"nodes": [
{"id": "Nginx", "group": 1},
{"id": "Wordpress", "group": 1},
{"id": "Memcached", "group": 1},
{"id": "Percona", "group": 1},
{"id": "NFS", "group": 1}
],
"links": [
{"source": "Nginx", "target": "Wordpress", "value": 1},
{"source": "Wordpress", "target": "Memcached", "value": 8},
{"source": "Wordpress", "target": "NFS", "value": 8},
{"source": "Wordpress", "target": "Percona", "value": 8}
]
}

View File

@ -0,0 +1,9 @@
# Sigma.js
This is an interesting library to be visulising large networks, however lacks an easy way to modify nodes, instead it is needed to re-write the renderer for the nodes to enable this, and the same would have to be done for (svg, canvas and webgl).
Sigma.js also has the problems that each individual node needs to have a specific value defined for an z and y coordinate, their are plugins that do implement a force graph layout, but due to the nature of the architecture of sigma.js it seems much more complicated to get a layout which makes the most amount of sense.
Therefore, for small networks, with rich information for each node, sigma.js is not currently the best choice, however if a need to visulise a whole network spanning multiple regions, projects and services, it could be a worthy avenenue to persue.
![screenshot from 2016-11-07 13-31-09](https://cloud.githubusercontent.com/assets/524382/20059506/7d57579e-a4ee-11e6-8f24-f0be0067f797.png)

View File

@ -0,0 +1,20 @@
<div id="container">
<style>
#graph-container {
top: 0;
bottom: 0;
left: 0;
right: 0;
position: absolute;
}
</style>
<div id="graph-container"></div>
</div>
<script src="vendor/sigma.js"></script>
<script src="vendor/plugins/sigma.parsers.json.min.js"></script>
<!-- <script src="vendor/plugins/sigma.renderers.parallelEdges.min.js"></script> -->
<script>
sigma.parsers.json('services.json', {
container: 'graph-container'
});
</script>

View File

@ -0,0 +1,15 @@
{
"nodes": [
{"id": "Nginx", "x": 3, "y": 1, "color": "rgb(255,204,102)", "size": 4.0},
{"id": "Wordpress", "x": 9, "y": 3, "size": 3},
{"id": "Memcached", "x": 7, "y": 5, "size": 3},
{"id": "Percona", "x": 6, "y": 7, "size": 3},
{"id": "NFS", "x": 3, "y": 5, "size": 3}
],
"edges": [
{"id": "1", "source": "Nginx", "target": "Wordpress"},
{"id": "2", "source": "Wordpress", "target": "Memcached"},
{"id": "3", "source": "Wordpress", "target": "NFS"},
{"id": "4", "source": "Wordpress", "target": "Percona"}
]
}

View File

@ -0,0 +1,35 @@
[![Build Status](https://travis-ci.org/jacomyal/sigma.js.svg)](https://travis-ci.org/jacomyal/sigma.js)
sigma.js - v1.2.0
=================
Sigma is a JavaScript library dedicated to graph drawing, mainly developed by [@jacomyal](https://github.com/jacomyal) and [@Yomguithereal](https://github.com/Yomguithereal).
### Resources
[The website](http://sigmajs.org) provides a global overview of the project, and the documentation is available in the [Github Wiki](https://github.com/jacomyal/sigma.js/wiki).
Also, the `plugins` and `examples` directories contain various use-cases that might help you understand how to use sigma.
### How to use it
To use it, clone the repository:
```
git clone git@github.com:jacomyal/sigma.js.git
```
To build the code:
- Install [Node.js](http://nodejs.org/).
- Install [gjslint](https://developers.google.com/closure/utilities/docs/linter_howto?hl=en).
- Use `npm install` to install sigma development dependencies.
- Use `npm run build` to minify the code with [Uglify](https://github.com/mishoo/UglifyJS). The minified file `sigma.min.js` will then be accessible in the `build/` folder.
Also, you can customize the build by adding or removing files from the `coreJsFiles` array in `Gruntfile.js` before applying the grunt task.
### Contributing
You can contribute by submitting [issues tickets](http://github.com/jacomyal/sigma.js/issues) and proposing [pull requests](http://github.com/jacomyal/sigma.js/pulls). Make sure that tests and linting pass before submitting any pull request by running the command `grunt`.
The whole source code is validated by the [Google Closure Linter](https://developers.google.com/closure/utilities/) and [JSHint](http://www.jshint.com/), and the comments are written in [JSDoc](http://en.wikipedia.org/wiki/JSDoc) (tags description is available [here](https://developers.google.com/closure/compiler/docs/js-for-compiler)).

View File

@ -0,0 +1 @@
(function(a){"use strict";function b(a){return new Blob([a],{type:"image/svg+xml;charset=utf-8"})}function c(a,c){var d=b(a),f={};f.anchor=document.createElement("a"),f.anchor.setAttribute("href",e.createObjectURL(d)),f.anchor.setAttribute("download",c);var g=document.createEvent("MouseEvent");g.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),e.revokeObjectURL(d),f.anchor.dispatchEvent(g),delete f.anchor}function d(a,b,c){var d,e,f,h,i,j={},k={},l=0,m="";c.classes&&(e=document.createElementNS(g,"style"),a.insertBefore(e,a.firstChild));var n=a.querySelectorAll('[id="'+b+'-group-nodes"] > [class="'+b+'-node"]');for(h=0,i=n.length,f=!0;h<i;h++)d=n[h].getAttribute("fill"),c.data||n[h].removeAttribute("data-node-id"),c.classes&&(d in j||(j[d]=f?b+"-node":"c-"+l++,m+="."+j[d]+"{fill: "+d+"}"),j[d]!==b+"-node"&&n[h].setAttribute("class",n[h].getAttribute("class")+" "+j[d]),n[h].removeAttribute("fill")),f=!1;var o=a.querySelectorAll('[id="'+b+'-group-edges"] > [class="'+b+'-edge"]');for(h=0,i=o.length,f=!0;h<i;h++)d=o[h].getAttribute("stroke"),c.data||o[h].removeAttribute("data-edge-id"),c.classes&&(d in k||(k[d]=f?b+"-edge":"c-"+l++,m+="."+k[d]+"{stroke: "+d+"}"),k[d]!==b+"-edge"&&o[h].setAttribute("class",o[h].getAttribute("class")+" "+k[d]),o[h].removeAttribute("stroke")),f=!1;c.classes&&e.appendChild(document.createTextNode(m))}if("undefined"==typeof sigma)throw"sigma.renderers.snapshot: sigma not in scope.";var e=this.URL||this.webkitURL||this,f={size:"1000",width:"1000",height:"1000",classes:!0,labels:!0,data:!1,download:!1,filename:"graph.svg"},g="http://www.w3.org/2000/svg";sigma.prototype.toSVG=function(a){a=a||{};var b=this.settings("classPrefix"),e=a.size||a.width||f.size,g=a.size||a.height||f.size,h=document.createElement("div");h.setAttribute("width",e),h.setAttribute("height",g),h.setAttribute("style","position:absolute; top: 0px; left:0px; width: "+e+"px; height: "+g+"px;");var i=this.addCamera(),j=this.addRenderer({camera:i,container:h,type:"svg",forceLabels:!!a.labels});j.resize(e,g),this.refresh(),this.killRenderer(j),this.killCamera(i);var k=h.querySelector("svg");if(k.removeAttribute("style"),k.setAttribute("width",e+"px"),k.setAttribute("height",g+"px"),k.setAttribute("x","0px"),k.setAttribute("y","0px"),!a.labels){var l=k.querySelector('[id="'+b+'-group-labels"]');k.removeChild(l)}var m=k.querySelector('[id="'+b+'-group-hovers"]');k.removeChild(m),a.classes=a.classes!==!1,a.data&&!a.classes||d(k,b,a);var n=k.outerHTML;h=null;var o='<?xml version="1.0" encoding="utf-8"?>\n';return o+='<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n',o+=n,a.download&&c(o,a.filename||f.filename),o}}).call(this);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(function(a){"use strict";function b(){var a=this;this.init=function(a,b){if(b=b||{},this.sigInst=a,this.config=sigma.utils.extend(b,c),this.easing=b.easing,this.duration=b.duration,b.nodes&&(this.nodes=b.nodes,delete b.nodes),!sigma.plugins||"undefined"==typeof sigma.plugins.animate)throw new Error("sigma.plugins.animate is not declared");this.running=!1},this.atomicGo=function(){if(!this.running||this.iterCount<1)return!1;var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w=this.nodes||this.sigInst.graph.nodes(),x=w.length,y=1/0,z=-(1/0),A=1/0,B=-(1/0);for(this.iterCount--,this.running=!1,b=0;b<x;b++)c=w[b],c.dn.dx=0,c.dn.dy=0,y=Math.min(y,c.dn_x-(c.dn_size*a.config.scaleNodes+a.config.nodeMargin)),z=Math.max(z,c.dn_x+(c.dn_size*a.config.scaleNodes+a.config.nodeMargin)),A=Math.min(A,c.dn_y-(c.dn_size*a.config.scaleNodes+a.config.nodeMargin)),B=Math.max(B,c.dn_y+(c.dn_size*a.config.scaleNodes+a.config.nodeMargin));for(e=z-y,f=B-A,g=(y+z)/2,h=(A+B)/2,y=g-a.config.permittedExpansion*e/2,z=g+a.config.permittedExpansion*e/2,A=h-a.config.permittedExpansion*f/2,B=h+a.config.permittedExpansion*f/2,i={},j=0;j<a.config.gridSize;j++)for(i[j]={},k=0;k<a.config.gridSize;k++)i[j][k]=[];for(b=0;b<x;b++)for(c=w[b],s=c.dn_x-(c.dn_size*a.config.scaleNodes+a.config.nodeMargin),t=c.dn_x+(c.dn_size*a.config.scaleNodes+a.config.nodeMargin),u=c.dn_y-(c.dn_size*a.config.scaleNodes+a.config.nodeMargin),v=c.dn_y+(c.dn_size*a.config.scaleNodes+a.config.nodeMargin),l=Math.floor(a.config.gridSize*(s-y)/(z-y)),m=Math.floor(a.config.gridSize*(t-y)/(z-y)),n=Math.floor(a.config.gridSize*(u-A)/(B-A)),o=Math.floor(a.config.gridSize*(v-A)/(B-A)),k=l;k<=m;k++)for(j=n;j<=o;j++)i[j][k].push(c.id);for(p={},j=0;j<a.config.gridSize;j++)for(k=0;k<a.config.gridSize;k++)i[j][k].forEach(function(b){for(p[b]||(p[b]=[]),q=Math.max(0,j-1);q<=Math.min(j+1,a.config.gridSize-1);q++)for(r=Math.max(0,k-1);r<=Math.min(k+1,a.config.gridSize-1);r++)i[q][r].forEach(function(a){a!==b&&p[b].indexOf(a)===-1&&p[b].push(a)})});for(b=0;b<x;b++)d=w[b],p[d.id].forEach(function(b){var c=a.sigInst.graph.nodes(b),g=c.dn_x-d.dn_x,h=c.dn_y-d.dn_y,i=Math.sqrt(g*g+h*h),j=i<d.dn_size*a.config.scaleNodes+a.config.nodeMargin+(c.dn_size*a.config.scaleNodes+a.config.nodeMargin);j&&(a.running=!0,i>0?(c.dn.dx+=g/i*(1+d.dn_size),c.dn.dy+=h/i*(1+d.dn_size)):(c.dn.dx+=.01*e*(.5-Math.random()),c.dn.dy+=.01*f*(.5-Math.random())))});for(b=0;b<x;b++)c=w[b],c.fixed||(c.dn_x=c.dn_x+.1*c.dn.dx*a.config.speed,c.dn_y=c.dn_y+.1*c.dn.dy*a.config.speed);return this.running&&this.iterCount<1&&(this.running=!1),this.running},this.go=function(){for(this.iterCount=this.config.maxIterations;this.running;)this.atomicGo();this.stop()},this.start=function(){if(!this.running){var b=this.sigInst.graph.nodes(),c=this.sigInst.renderers[a.config.rendererIndex].options.prefix;this.running=!0;for(var d=0;d<b.length;d++)b[d].dn_x=b[d][c+"x"],b[d].dn_y=b[d][c+"y"],b[d].dn_size=b[d][c+"size"],b[d].dn={dx:0,dy:0};e[a.sigInst.id].dispatchEvent("start"),this.go()}},this.stop=function(){var b=this.sigInst.graph.nodes();if(this.running=!1,this.easing)e[a.sigInst.id].dispatchEvent("interpolate"),sigma.plugins.animate(a.sigInst,{x:"dn_x",y:"dn_y"},{easing:a.easing,onComplete:function(){a.sigInst.refresh();for(var c=0;c<b.length;c++)b[c].dn=null,b[c].dn_x=null,b[c].dn_y=null;e[a.sigInst.id].dispatchEvent("stop")},duration:a.duration});else{for(var c=0;c<b.length;c++)b[c].x=b[c].dn_x,b[c].y=b[c].dn_y;this.sigInst.refresh();for(var c=0;c<b.length;c++)b[c].dn=null,b[c].dn_x=null,b[c].dn_y=null;e[a.sigInst.id].dispatchEvent("stop")}},this.kill=function(){this.sigInst=null,this.config=null,this.easing=null}}if("undefined"==typeof sigma)throw new Error("sigma is not declared");sigma.utils.pkg("sigma.layout.noverlap");var c={speed:3,scaleNodes:1.2,nodeMargin:5,gridSize:20,permittedExpansion:1.1,rendererIndex:0,maxIterations:500},d={},e={};sigma.prototype.configNoverlap=function(a){var c=this;if(!a)throw new Error('Missing argument: "config"');return d[c.id]||(d[c.id]=new b,e[c.id]={},sigma.classes.dispatcher.extend(e[c.id]),c.bind("kill",function(){d[c.id].kill(),d[c.id]=null,e[c.id]=null})),d[c.id].init(c,a),e[c.id]},sigma.prototype.startNoverlap=function(a){var b=this;return a&&this.configNoverlap(b,a),d[b.id].start(),e[b.id]},sigma.prototype.isNoverlapRunning=function(){var a=this;return!!d[a.id]&&d[a.id].running}}).call(this);

View File

@ -0,0 +1 @@
(function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.neo4j"),sigma.utils.pkg("sigma.utils"),sigma.neo4j.send=function(a,b,c,d,e){var f,g,h,i=sigma.utils.xhr();if(f=a,"object"==typeof a&&(f=a.url,g=a.user,h=a.password),!i)throw"XMLHttpRequest not supported, cannot load the file.";f+=b,i.open(c,f,!0),g&&h&&i.setRequestHeader("Authorization","Basic "+btoa(g+":"+h)),i.setRequestHeader("Accept","application/json"),i.setRequestHeader("Content-type","application/json; charset=utf-8"),i.onreadystatechange=function(){4===i.readyState&&e(JSON.parse(i.responseText))},i.send(d)},sigma.neo4j.cypher_parse=function(a){var b,c={nodes:[],edges:[]},d={},e={};a.results[0].data.forEach(function(a){a.graph.nodes.forEach(function(a){var b={id:a.id,label:a.id,x:Math.random(),y:Math.random(),size:1,color:"#000000",neo4j_labels:a.labels,neo4j_data:a.properties};b.id in d||(d[b.id]=b)}),a.graph.relationships.forEach(function(a){var b={id:a.id,label:a.type,source:a.startNode,target:a.endNode,color:"#7D7C8E",neo4j_type:a.type,neo4j_data:a.properties};b.id in e||(e[b.id]=b)})});for(b in d)c.nodes.push(d[b]);for(b in e)c.edges.push(e[b]);return c},sigma.neo4j.cypher=function(a,b,c,d){var e,f,g="/db/data/transaction/commit";e=JSON.stringify({statements:[{statement:b,resultDataContents:["graph"],includeStats:!1}]}),f=function(a){return function(b){var d={nodes:[],edges:[]};d=sigma.neo4j.cypher_parse(b),c instanceof sigma?(c.graph.clear(),c.graph.read(d)):"object"==typeof c?(c=new sigma(c),c.graph.read(d),c.refresh()):"function"==typeof c&&(a=c,c=null),a&&a(c||d)}},sigma.neo4j.send(a,g,"POST",e,f(d))},sigma.neo4j.getLabels=function(a,b){sigma.neo4j.send(a,"/db/data/labels","GET",null,b)},sigma.neo4j.getTypes=function(a,b){sigma.neo4j.send(a,"/db/data/relationship/types","GET",null,b)}}).call(this);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.parsers"),sigma.utils.pkg("sigma.utils"),sigma.utils.xhr=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;var a,b;if(window.ActiveXObject){a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(b in a)try{return new ActiveXObject(a[b])}catch(a){}}return null},sigma.parsers.json=function(a,b,c){var d,e=sigma.utils.xhr();if(!e)throw"XMLHttpRequest not supported, cannot load the file.";e.open("GET",a,!0),e.onreadystatechange=function(){4===e.readyState&&(d=JSON.parse(e.responseText),b instanceof sigma?(b.graph.clear(),b.graph.read(d)):"object"==typeof b?(b.graph=d,b=new sigma(b)):"function"==typeof b&&(c=b,b=null),c&&c(b||d))},e.send()}}).call(this);

View File

@ -0,0 +1 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";var a=function(a,b,c){var d=void 0!=a&&void 0!=b&&void 0!=a.x&&void 0!=a.y&&void 0!=b.x&&void 0!=b.y;if(d)return(c||0)+Math.sqrt(Math.pow(b.y-a.y,2)+Math.pow(b.x-a.x,2))};sigma.classes.graph.addMethod("astar",function(b,c,d){var e=new sigma.classes.configurable({undirected:!1,pathLengthFunction:a,heuristicLengthFunction:void 0},d||{}),f=e("pathLengthFunction"),g=e("heuristicLengthFunction")||f,h=this.nodes(b),i=this.nodes(c),j={},k=[],l=function(a,b,c,d){var e=a.id,f={pathLength:c,heuristicLength:d,node:a,nodeId:e,previousNode:b};if(void 0==j[e]||j[e].pathLenth>c){j[e]=f;var g,h;for(h=0;h<k.length&&(g=k[h],!(g.heuristicLength>d));h++);k.splice(h,0,f)}};l(h,null,0,0);var m,n=!1;m=e("undirected")?this.allNeighborsIndex:this.outNeighborsIndex;for(var o,p,q,r,s,t;k.length>0;){if(o=k.shift(),o.nodeId==c){n=!0;break}for(p=Object.keys(m[o.nodeId]),t=0;t<p.length;t++)q=this.nodes(p[t]),r=f(o.node,q,o.pathLength),s=g(q,i),l(q,o.node,r,s)}if(n){for(var u=[],v=i;v;)u.unshift(v),v=j[v.id].previousNode;return u}})}).call(window);

View File

@ -0,0 +1 @@
(function(){"use strict";function a(a){if(d[a])return d[a];var b=[0,0,0];return a.match(/^#/)?(a=(a||"").replace(/^#/,""),b=3===a.length?[parseInt(a.charAt(0)+a.charAt(0),16),parseInt(a.charAt(1)+a.charAt(1),16),parseInt(a.charAt(2)+a.charAt(2),16)]:[parseInt(a.charAt(0)+a.charAt(1),16),parseInt(a.charAt(2)+a.charAt(3),16),parseInt(a.charAt(4)+a.charAt(5),16)]):a.match(/^ *rgba? *\(/)&&(a=a.match(/^ *rgba? *\( *([0-9]*) *, *([0-9]*) *, *([0-9]*) *(,.*)?\) *$/),b=[+a[1],+a[2],+a[3]]),d[a]={r:b[0],g:b[1],b:b[2]},d[a]}function b(b,c,d){b=a(b),c=a(c);var e={r:b.r*(1-d)+c.r*d,g:b.g*(1-d)+c.g*d,b:b.b*(1-d)+c.b*d};return"rgb("+[0|e.r,0|e.g,0|e.b].join(",")+")"}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");var c=0,d={};sigma.plugins.animate=function(a,d,e){function f(){var c=(sigma.utils.dateNow()-m)/k;if(c>=1){g.forEach(function(a){for(var b in d)b in d&&(a[b]=a[d[b]])});var e,n;for(e in a.cameras)n=a.cameras[e],n.edgequadtree._enabled=!0;a.refresh(),"function"==typeof i.onComplete&&i.onComplete()}else c=l(c),g.forEach(function(a){for(var e in d)e in d&&(e.match(/color$/)?a[e]=b(h[a.id][e],a[d[e]],c):a[e]=a[d[e]]*c+h[a.id][e]*(1-c))}),a.refresh(),a.animations[j]=requestAnimationFrame(f)}var g,h,i=e||{},j=++c,k=i.duration||a.settings("animationsTime"),l="string"==typeof i.easing?sigma.utils.easings[i.easing]:"function"==typeof i.easing?i.easing:sigma.utils.easings.quadraticInOut,m=sigma.utils.dateNow();g=i.nodes&&i.nodes.length?"object"==typeof i.nodes[0]?i.nodes:a.graph.nodes(i.nodes):a.graph.nodes(),h=g.reduce(function(a,b){var c;a[b.id]={};for(c in d)c in b&&(a[b.id][c]=b[c]);return a},{}),a.animations=a.animations||Object.create({}),sigma.plugins.kill(a);var n,o;for(n in a.cameras)o=a.cameras[n],o.edgequadtree._enabled=!1;f()},sigma.plugins.kill=function(a){for(var b in a.animations||{})cancelAnimationFrame(a.animations[b]);var b,c;for(b in a.cameras)c=a.cameras[b],c.edgequadtree._enabled=!0}}).call(window);

View File

@ -0,0 +1 @@
(function(){"use strict";function a(a,b){function c(a){var b=window.getComputedStyle(a),c=function(a){return parseInt(b.getPropertyValue(a).replace("px",""))||0};return{left:a.getBoundingClientRect().left+c("padding-left"),top:a.getBoundingClientRect().top+c("padding-top")}}function d(a){t=!1,l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h),r.length||(p=null)}function e(a){s[a.data.node.id]||(r.push(a.data.node),s[a.data.node.id]=!0,r.length&&!t&&(p=r[r.length-1],n.addEventListener("mousedown",g)))}function f(a){var b=r.map(function(a){return a}).indexOf(a.data.node);r.splice(b,1),delete s[a.data.node.id],r.length&&!t?p=r[r.length-1]:n.removeEventListener("mousedown",g)}function g(a){t=!0;var b=k.graph.nodes().length;if(p&&b>1){n.removeEventListener("mousedown",g),l.addEventListener("mousemove",i),l.addEventListener("mouseup",h);var c,d;for(c in k.cameras)d=k.cameras[c],void 0!==d.edgequadtree&&(d.edgequadtree._enabled=!1);m.settings({mouseEnabled:!1,enableHovering:!1}),k.refresh(),j.dispatchEvent("startdrag",{node:p,captor:a,renderer:m})}}function h(a){t=!1,n.addEventListener("mousedown",g),l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h);var b,c;for(b in k.cameras)c=k.cameras[b],void 0!==c.edgequadtree&&(c.edgequadtree._enabled=!0);m.settings({mouseEnabled:!0,enableHovering:!0}),k.refresh(),u&&j.dispatchEvent("drop",{node:p,captor:a,renderer:m}),j.dispatchEvent("dragend",{node:p,captor:a,renderer:m}),u=!1,p=null}function i(a){function b(){for(var b=c(m.container),d=a.clientX-b.left,e=a.clientY-b.top,f=Math.cos(o.angle),g=Math.sin(o.angle),h=k.graph.nodes(),i=[],l=0;l<2;l++){var n=h[l],r={x:n.x*f+n.y*g,y:n.y*f-n.x*g,renX:n[q+"x"],renY:n[q+"y"]};i.push(r)}if(i[0].x===i[1].x&&i[0].y===i[1].y){var s=0===i[0].renX?1:i[0].renX,t=0===i[0].renY?1:i[0].renY;d=i[0].x/s*(d-i[0].renX)+i[0].x,e=i[0].y/t*(e-i[0].renY)+i[0].y}else{var s=(i[1].renX-i[0].renX)/(i[1].x-i[0].x),t=(i[1].renY-i[0].renY)/(i[1].y-i[0].y);i[1].x===i[0].x&&(s=t),i[1].y===i[0].y&&(t=s),d=(d-i[0].renX)/s+i[0].x,e=(e-i[0].renY)/t+i[0].y}p.x=d*f-e*g,p.y=e*f+d*g,k.refresh(),u=!0,j.dispatchEvent("drag",{node:p,captor:a,renderer:m})}if(navigator.userAgent.toLowerCase().indexOf("firefox")>-1){clearTimeout(d);var d=setTimeout(b,0)}else b()}sigma.classes.dispatcher.extend(this);var j=this,k=a,l=document.body,m=b,n=b.container.lastChild,o=b.camera,p=null,q="",r=[],s={},t=!1,u=!1;b instanceof sigma.renderers.svg&&(n=b.container.firstChild),q=b instanceof sigma.renderers.webgl?b.options.prefix.substr(5):b.options.prefix,b.bind("overNode",e),b.bind("outNode",f),b.bind("click",d),k.bind("kill",function(){j.unbindAll()}),this.unbindAll=function(){n.removeEventListener("mousedown",g),l.removeEventListener("mousemove",i),l.removeEventListener("mouseup",h),m.unbind("overNode",e),m.unbind("outNode",f)}}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");var b={};sigma.plugins.dragNodes=function(c,d){return b[c.id]||(b[c.id]=new a(c,d)),c.bind("kill",function(){sigma.plugins.killDragNodes(c)}),b[c.id]},sigma.plugins.killDragNodes=function(c){b[c.id]instanceof a&&(b[c.id].unbindAll(),delete b[c.id])}}).call(window);

View File

@ -0,0 +1 @@
(function(undefined){"use strict";function register(a,b,c){if(c!=undefined&&"string"!=typeof c)throw'The filter key "'+c.toString()+'" must be a string.';if(c!=undefined&&!c.length)throw"The filter key must be a non-empty string.";if("function"!=typeof a)throw'The predicate of key "'+c+'" must be a function.';if("undo"===c)throw'"undo" is a reserved key.';if(_keysIndex[c])throw'The filter "'+c+'" already exists.';c&&(_keysIndex[c]=!0),_chain.push({key:c,processor:a,predicate:b})}function unregister(a){_chain=_chain.filter(function(b){return!(b.key in a)});for(var b in a)delete _keysIndex[b]}function Filter(a){_s=a,_g=a.graph}function deepCopy(o){var copy=Object.create(null);for(var i in o)"object"==typeof o[i]&&null!==o[i]?copy[i]=deepCopy(o[i]):"function"==typeof o[i]&&null!==o[i]?eval(" copy[i] = "+o[i].toString()):copy[i]=o[i];return copy}function cloneChain(a){for(var b=a.slice(0),c=0,d=b.length;c<d;c++)b[c]=deepCopy(b[c]),"function"==typeof b[c].processor&&(b[c].processor="filter.processors."+b[c].processor.name);return b}if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins"),sigma.classes.graph.hasMethod("adjacentNodes")||sigma.classes.graph.addMethod("adjacentNodes",function(a){if("string"!=typeof a)throw"adjacentNodes: the node id must be a string.";var b,c=[];for(b in this.allNeighborsIndex[a])c.push(this.nodesIndex[b]);return c}),sigma.classes.graph.hasMethod("adjacentEdges")||sigma.classes.graph.addMethod("adjacentEdges",function(a){if("string"!=typeof a)throw"adjacentEdges: the node id must be a string.";var b,c,d=this.allNeighborsIndex[a],e=[];for(c in d)for(b in d[c])e.push(d[c][b]);return e});var _g=undefined,_s=undefined,_chain=[],_keysIndex=Object.create(null),Processors={};Processors.nodes=function(a){for(var b=_g.nodes(),c=b.length,d=_g.edges(),e=d.length;c--;)b[c].hidden=!a.call(_g,b[c])||b[c].hidden;for(;e--;)(_g.nodes(d[e].source).hidden||_g.nodes(d[e].target).hidden)&&(d[e].hidden=!0)},Processors.edges=function(a){for(var b=_g.edges(),c=b.length;c--;)b[c].hidden=!a.call(_g,b[c])||b[c].hidden},Processors.neighbors=function a(b){for(var c=_g.nodes(),d=c.length,e=_g.edges(),f=e.length,a=_g.adjacentNodes(b),g=a.length,h={};g--;)h[a[g].id]=!0;for(;d--;)c[d].id===b||c[d].id in h||(c[d].hidden=!0);for(;f--;)(_g.nodes(e[f].source).hidden||_g.nodes(e[f].target).hidden)&&(e[f].hidden=!0)},Filter.prototype.nodesBy=function(a,b){return register(Processors.nodes,a,b),this},Filter.prototype.edgesBy=function(a,b){return register(Processors.edges,a,b),this},Filter.prototype.neighborsOf=function(a,b){if("string"!=typeof a)throw'The node id "'+a.toString()+'" must be a string.';if(!a.length)throw"The node id must be a non-empty string.";return register(Processors.neighbors,a,b),this},Filter.prototype.apply=function(){for(var a=0,b=_chain.length;a<b;++a)_chain[a].processor(_chain[a].predicate);return _chain[0]&&"undo"===_chain[0].key&&_chain.shift(),_s.refresh(),this},Filter.prototype.undo=function(a){function b(){for(var a=_g.nodes(),b=a.length,c=_g.edges(),d=c.length;b--;)a[b].hidden=!1;for(;d--;)c[d].hidden=!1}var c=Object.create(null),d=arguments.length;if(1===d)if("[object Array]"===Object.prototype.toString.call(a))for(var e=0,f=a.length;e<f;e++)c[a[e]]=!0;else c[a]=!0;else if(d>1)for(var e=0;e<d;e++)c[arguments[e]]=!0;else this.clear();return unregister(c),_chain.unshift({key:"undo",processor:b}),this},Filter.prototype.clear=function(){return _chain.length=0,_keysIndex=Object.create(null),this},Filter.prototype.export=function(){var a=cloneChain(_chain);return a},Filter.prototype.import=function(a){if(a===undefined)throw"Wrong arguments.";if("[object Array]"!==Object.prototype.toString.call(a))throw'The chain" must be an array.';for(var b=cloneChain(a),c=0,d=b.length;c<d;c++){if(b[c].predicate===undefined||b[c].processor===undefined)throw"Wrong arguments.";if(b[c].key!=undefined&&"string"!=typeof b[c].key)throw'The filter key "'+b[c].key.toString()+'" must be a string.';if("function"!=typeof b[c].predicate)throw'The predicate of key "'+b[c].key+'" must be a function.';if("string"!=typeof b[c].processor)throw'The processor of key "'+b[c].key+'" must be a string.';switch(b[c].processor){case"filter.processors.nodes":b[c].processor=Processors.nodes;break;case"filter.processors.edges":b[c].processor=Processors.edges;break;case"filter.processors.neighbors":b[c].processor=Processors.neighbors;break;default:throw"Unknown processor "+b[c].processor}}return _chain=b,this};var filter=null;sigma.plugins.filter=function(a){return filter||(filter=new Filter(a)),filter}}).call(this);

View File

@ -0,0 +1 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.classes.graph.addMethod("neighborhood",function(a){var b,c,d,e,f,g={},h={},i={nodes:[],edges:[]};if(!this.nodes(a))return i;e=this.nodes(a),f={},f.center=!0;for(b in e)f[b]=e[b];g[a]=!0,i.nodes.push(f);for(b in this.allNeighborsIndex[a]){g[b]||(g[b]=!0,i.nodes.push(this.nodesIndex[b]));for(c in this.allNeighborsIndex[a][b])h[c]||(h[c]=!0,i.edges.push(this.edgesIndex[c]))}for(b in g)if(b!==a)for(c in g)if(c!==a&&b!==c&&this.allNeighborsIndex[b][c])for(d in this.allNeighborsIndex[b][c])h[d]||(h[d]=!0,i.edges.push(this.edgesIndex[d]));return i}),sigma.utils.pkg("sigma.plugins"),sigma.plugins.neighborhoods=function(){var a=new sigma.classes.graph;this.neighborhood=function(b){return a.neighborhood(b)},this.load=function(b,c){var d=function(){if(window.XMLHttpRequest)return new XMLHttpRequest;var a,b;if(window.ActiveXObject){a=["Msxml2.XMLHTTP.6.0","Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP"];for(b in a)try{return new ActiveXObject(a[b])}catch(a){}}return null}();if(!d)throw"XMLHttpRequest not supported, cannot load the data.";return d.open("GET",b,!0),d.onreadystatechange=function(){4===d.readyState&&(a.clear().read(JSON.parse(d.responseText)),c&&c())},d.send(),this},this.read=function(b){a.clear().read(b)}}}).call(window);

View File

@ -0,0 +1 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.plugins");sigma.plugins.relativeSize=function(a,b){for(var c=a.graph.nodes(),d=0;d<c.length;d++){var e=a.graph.degree(c[d].id);c[d].size=b*Math.sqrt(e)}a.refresh()}}).call(window);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
!function(){"use strict";function a(a,b,c,d,f,g,h,i,j){a.beginPath(),a.fillStyle=j;var k=e(b,c,d.x,d.y,f,g,h);a.arc(k.x,k.y,3*i,0,2*Math.PI,!1),a.fill()}function b(a,b,c,d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function c(a,c,d,e,f,g,h){return{x:b(h,a,d,f),y:b(h,c,e,g)}}function d(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function e(a,b,e,f,g,h,i){for(var j=0,k=1e3,l=.001,m=0;m<1;m+=l){var n=c(a,b,e,f,g,h,m),o=d(a,b,n.x,n.y);Math.abs(o-i)<k&&(k=Math.abs(o-i),j=m)}return c(a,b,e,f,g,h,j)}sigma.utils.pkg("sigma.canvas.edges"),sigma.canvas.edges.dotCurve=function(b,c,d,e,f){var g=b.color,h=f("prefix")||"",i=b[h+"size"]||1,j=f("edgeColor"),k=f("defaultNodeColor"),l=f("defaultEdgeColor"),m={},n=c[h+"size"],o=c[h+"x"],p=c[h+"y"],q=d[h+"x"],r=d[h+"y"];if(m=c.id===d.id?sigma.utils.getSelfLoopControlPoints(o,p,n):sigma.utils.getQuadraticControlPoint(o,p,q,r),!g)switch(j){case"source":g=c.color||k;break;case"target":g=d.color||k;break;default:g=l}if(e.strokeStyle=g,e.lineWidth=i,e.beginPath(),e.moveTo(o,p),c.id===d.id?e.bezierCurveTo(m.x1,m.y1,m.x2,m.y2,q,r):e.quadraticCurveTo(m.x,m.y,q,r),e.stroke(),void 0!=b.sourceDotColor||void 0!=b.targetDotColor){var s=b.dotOffset||3,t=b.dotSize||1;t*=i,s*=n,void 0!=b.sourceDotColor&&a(e,o,p,m,q,r,s,t,b.sourceDotColor),void 0!=b.targetDotColor&&a(e,q,r,m,o,p,s,t,b.targetDotColor)}}}(),function(){"use strict";function a(a,b,c,d,f,g,h,i,j){a.beginPath(),a.fillStyle=j;var k=e(b,c,d.x,d.y,f,g,h);a.arc(k.x,k.y,3*i,0,2*Math.PI,!1),a.fill()}function b(a,b,c,d){var e=1-a;return e*e*b+2*e*a*c+a*a*d}function c(a,c,d,e,f,g,h){return{x:b(h,a,d,f),y:b(h,c,e,g)}}function d(a,b,c,d){return Math.sqrt((c-a)*(c-a)+(d-b)*(d-b))}function e(a,b,e,f,g,h,i){for(var j=0,k=1e3,l=.001,m=0;m<1;m+=l){var n=c(a,b,e,f,g,h,m),o=d(a,b,n.x,n.y);Math.abs(o-i)<k&&(k=Math.abs(o-i),j=m)}return c(a,b,e,f,g,h,j)}sigma.utils.pkg("sigma.canvas.edges"),sigma.canvas.edges.dotCurvedArrow=function(b,c,d,e,f){var g,h,i,j,k,l=b.color,m=f("prefix")||"",n=f("edgeColor"),o=f("defaultNodeColor"),p=f("defaultEdgeColor"),q={},r=b[m+"size"]||1,s=b.count||0,t=d[m+"size"],u=c[m+"x"],v=c[m+"y"],w=d[m+"x"],x=d[m+"y"],y=Math.max(2.5*r,f("minArrowSize"));if(q=c.id===d.id?sigma.utils.getSelfLoopControlPoints(u,v,t,s):sigma.utils.getQuadraticControlPoint(u,v,w,x,s),c.id===d.id?(g=Math.sqrt(Math.pow(w-q.x1,2)+Math.pow(x-q.y1,2)),h=q.x1+(w-q.x1)*(g-y-t)/g,i=q.y1+(x-q.y1)*(g-y-t)/g,j=(w-q.x1)*y/g,k=(x-q.y1)*y/g):(g=Math.sqrt(Math.pow(w-q.x,2)+Math.pow(x-q.y,2)),h=q.x+(w-q.x)*(g-y-t)/g,i=q.y+(x-q.y)*(g-y-t)/g,j=(w-q.x)*y/g,k=(x-q.y)*y/g),!l)switch(n){case"source":l=c.color||o;break;case"target":l=d.color||o;break;default:l=p}if(e.strokeStyle=l,e.lineWidth=r,e.beginPath(),e.moveTo(u,v),c.id===d.id?e.bezierCurveTo(q.x2,q.y2,q.x1,q.y1,h,i):e.quadraticCurveTo(q.x,q.y,h,i),e.stroke(),e.fillStyle=l,e.beginPath(),e.moveTo(h+j,i+k),e.lineTo(h+.6*k,i-.6*j),e.lineTo(h-.6*k,i+.6*j),e.lineTo(h+j,i+k),e.closePath(),e.fill(),void 0!=b.sourceDotColor||void 0!=b.targetDotColor){var z=b.dotOffset||3,A=b.dotSize||1;A*=r,z*=t,void 0!=b.sourceDotColor&&a(e,u,v,q,w,x,z,A,b.sourceDotColor),void 0!=b.targetDotColor&&a(e,w,x,q,u,v,z,A,b.targetDotColor)}}}();

View File

@ -0,0 +1 @@
(function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.settings");var b={defaultEdgeLabelColor:"#000",defaultEdgeLabelActiveColor:"#000",defaultEdgeLabelSize:10,edgeLabelSize:"fixed",edgeLabelSizePowRatio:1,edgeLabelThreshold:1};sigma.settings=sigma.utils.extend(sigma.settings||{},b),sigma.settings.drawEdgeLabels=!0}).call(this),function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.curve=function(a,b,c,d,e){if("string"==typeof a.label){var f=e("prefix")||"",g=a[f+"size"]||1;if(!(g<e("edgeLabelThreshold"))){var h,i,j,k=b[f+"size"],l=b[f+"x"],m=b[f+"y"],n=c[f+"x"],o=c[f+"y"],p=n-l,q=o-m,r=l<n?1:-1,s={},t=.5;b.id===c.id?(s=sigma.utils.getSelfLoopControlPoints(l,m,k),i=sigma.utils.getPointOnBezierCurve(t,l,m,n,o,s.x1,s.y1,s.x2,s.y2),j=Math.atan2(1,1)):(s=sigma.utils.getQuadraticControlPoint(l,m,n,o),i=sigma.utils.getPointOnQuadraticCurve(t,l,m,n,o,s.x,s.y),j=Math.atan2(q*r,p*r)),h="fixed"===e("edgeLabelSize")?e("defaultEdgeLabelSize"):e("defaultEdgeLabelSize")*g*Math.pow(g,-1/e("edgeLabelSizePowRatio")),d.save(),a.active?(d.font=[e("activeFontStyle"),h+"px",e("activeFont")||e("font")].join(" "),d.fillStyle="edge"===e("edgeActiveColor")?a.active_color||e("defaultEdgeActiveColor"):e("defaultEdgeLabelActiveColor")):(d.font=[e("fontStyle"),h+"px",e("font")].join(" "),d.fillStyle="edge"===e("edgeLabelColor")?a.color||e("defaultEdgeColor"):e("defaultEdgeLabelColor")),d.textAlign="center",d.textBaseline="alphabetic",d.translate(i.x,i.y),d.rotate(j),d.fillText(a.label,0,-g/2-3),d.restore()}}}}.call(this),function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.curvedArrow=function(a,b,c,d,e){sigma.canvas.edges.labels.curve(a,b,c,d,e)}}.call(this),function(a){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.utils.pkg("sigma.canvas.edges.labels"),sigma.canvas.edges.labels.def=function(a,b,c,d,e){if("string"==typeof a.label&&b!=c){var f=e("prefix")||"",g=a[f+"size"]||1;if(!(g<e("edgeLabelThreshold"))){if(0===e("edgeLabelSizePowRatio"))throw'"edgeLabelSizePowRatio" must not be 0.';var h,i=(b[f+"x"]+c[f+"x"])/2,j=(b[f+"y"]+c[f+"y"])/2,k=c[f+"x"]-b[f+"x"],l=c[f+"y"]-b[f+"y"],m=b[f+"x"]<c[f+"x"]?1:-1,n=Math.atan2(l*m,k*m);h="fixed"===e("edgeLabelSize")?e("defaultEdgeLabelSize"):e("defaultEdgeLabelSize")*g*Math.pow(g,-1/e("edgeLabelSizePowRatio")),d.save(),a.active?(d.font=[e("activeFontStyle"),h+"px",e("activeFont")||e("font")].join(" "),d.fillStyle="edge"===e("edgeActiveColor")?a.active_color||e("defaultEdgeActiveColor"):e("defaultEdgeLabelActiveColor")):(d.font=[e("fontStyle"),h+"px",e("font")].join(" "),d.fillStyle="edge"===e("edgeLabelColor")?a.color||e("defaultEdgeColor"):e("defaultEdgeLabelColor")),d.textAlign="center",d.textBaseline="alphabetic",d.translate(i,j),d.rotate(n),d.fillText(a.label,0,-g/2-3),d.restore()}}}}.call(this);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(function(a){function b(a,b,c){var d=document.createElement("a");d.setAttribute("href",a),d.setAttribute("download",c||"graph."+b);var e=document.createEvent("MouseEvent");e.initMouseEvent("click",!0,!1,window,0,0,0,0,0,!1,!1,!1,!1,0,null),d.dispatchEvent(e),delete d}function c(a){if(a=a||{},a.format&&!(a.format in e))throw Error('sigma.renderers.snaphot: unsupported format "'+a.format+'".');var c=this,f=this instanceof sigma.renderers.webgl,g=[],h=document.createElement("canvas"),i=h.getContext("2d"),j=!1;d.forEach(function(b){if(c.contexts[b]&&(a.labels!==!1||"labels"!==b)){var d=c.domElements[b]||c.domElements.scene,e=c.contexts[b];~g.indexOf(e)||(j||(h.width=f&&e instanceof WebGLRenderingContext?d.width/2:d.width,h.height=f&&e instanceof WebGLRenderingContext?d.height/2:d.height,j=!0,a.background&&(i.rect(0,0,h.width,h.height),i.fillStyle=a.background,i.fill())),e instanceof WebGLRenderingContext?i.drawImage(d,0,0,d.width/2,d.height/2):i.drawImage(d,0,0),g.push(e))}});var k=h.toDataURL(e[a.format||"png"]);return a.download&&b(k,a.format||"png",a.filename),delete i,delete h,delete g,k}if("undefined"==typeof sigma)throw"sigma.renderers.snapshot: sigma not in scope.";var d=["scene","edges","nodes","labels"],e={png:"image/png",jpg:"image/jpeg",gif:"image/gif",tiff:"image/tiff"};sigma.renderers.canvas.prototype.snapshot=c,sigma.renderers.webgl.prototype.snapshot=c}).call(this);

View File

@ -0,0 +1 @@
(function(){"use strict";if("undefined"==typeof sigma)throw"sigma is not declared";sigma.classes.graph.addMethod("HITS",function(a){var b={},c=1e-4,d=[],e=[],f=this.nodes(),g=(f.length,{});a||(a=!1);for(var h in f)a?(d.push(f[h]),e.push(f[h])):(this.degree(f[h].id,"out")>0&&d.push(f[h]),this.degree(f[h].id,"in")>0&&e.push(f[h])),b[f[h].id]={authority:1,hub:1};for(var i;;){i=!0;var j=0,k=0;for(var h in e){g[e[h].id]={authority:1,hub:0};var l=[];l=a?this.allNeighborsIndex[e[h].id]:this.inNeighborsIndex[e[h].id];for(var m in l)m!=e[h].id&&(g[e[h].id].authority+=b[m].hub);j+=g[e[h].id].authority}for(var h in d){g[d[h].id]?g[d[h].id].hub=1:g[d[h].id]={authority:0,hub:1};var l=[];l=a?this.allNeighborsIndex[d[h].id]:this.outNeighborsIndex[d[h].id];for(var m in l)m!=d[h].id&&(g[d[h].id].hub+=b[m].authority);k+=g[d[h].id].hub}for(var h in e)g[e[h].id].authority/=j,Math.abs((g[e[h].id].authority-b[e[h].id].authority)/b[e[h].id].authority)>=c&&(i=!1);for(var h in d)g[d[h].id].hub/=k,Math.abs((g[d[h].id].hub-b[d[h].id].hub)/b[d[h].id].hub)>=c&&(i=!1);if(b=g,g={},i)break}return b})}).call(window);

12055
spikes/architecture/sigmajs/vendor/sigma.js vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff