Skip to content

Commit

Permalink
start v2 branch
Browse files Browse the repository at this point in the history
  • Loading branch information
make-github-pseudonymous-again committed Jul 16, 2015
1 parent 5dc708d commit 69faa6f
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions js/src/undirected/online/data/fuse.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/**
* Fuse multiple graph data structure allowing to
* repeat the same write operations on all of them.
Expand All @@ -6,59 +7,60 @@
* vertices in other fused graphs.
*/

var fuse_t = function(){

var fuse = function(){
const fuse = function ( map , graphs ) {

return new Fused( map , graphs ) ;

} ;

this.obj = Array.prototype.slice.call(arguments);

};
const Fused = function ( map , graphs ) {

this.map = map ;
this.graphs = graphs ;

fuse.prototype.vadd = function(h){
var i = 0, len = this.obj.length;
var pt = new Array(len);

for(; i < len; ++i){
pt[i] = this.obj[i].vadd(h);
pt[i].pt = pt;
}
} ;

pt.pt = pt;
Fused.prototype.vadd = function ( h ) {

return pt;
};
const vertices = [ for ( g of this.graphs ) g.vadd( h ) ] ;

fuse.prototype.eadd = function(u, v, w){
var i = 0, len = this.obj.length;
var pt = new Array(len);
for(; i < len; ++i){
pt[i] = this.obj[i].eadd(u.pt[i], v.pt[i], w);
pt[i].pt = pt;
}

pt.pt = pt;
for( let v of vertices ) this.map.set( v , vertices ) ;

return pt;
};
this.map.set( vertices , vertices ) ;

return vertices ;

fuse.prototype.vdel = function(v){
var i = 0, len = this.obj.length;
for(; i < len; ++i){
this.obj[i].vdel(v.pt[i]);
}
};
} ;

fuse.prototype.edel = function(e){
var i = 0, len = this.obj.length;
for(; i < len; ++i){
this.obj[i].edel(e.pt[i]);
}
};
Fused.prototype.eadd = function(u, v, w){
var i = 0, len = this.graphs.length;
var pt = new Array(len);
for(; i < len; ++i){
pt[i] = this.graphs[i].eadd(u.pt[i], v.pt[i], w);
pt[i].pt = pt;
}

return fuse;
pt.pt = pt;

return pt;
};


Fused.prototype.vdel = function(v){
var i = 0, len = this.graphs.length;
for(; i < len; ++i){
this.graphs[i].vdel(v.pt[i]);
}
};

Fused.prototype.edel = function(e){
var i = 0, len = this.graphs.length;
for(; i < len; ++i){
this.graphs[i].edel(e.pt[i]);
}
};


exports.fuse_t = fuse_t;

0 comments on commit 69faa6f

Please sign in to comment.