Skip to content

Instantly share code, notes, and snippets.

@dz1984
Created October 9, 2015 12:09
Show Gist options
  • Save dz1984/dad3faa8e98e98b9ee89 to your computer and use it in GitHub Desktop.
Save dz1984/dad3faa8e98e98b9ee89 to your computer and use it in GitHub Desktop.
(function(){
console.log('script init');
var Vertox = function(label){
var _str = function(label) {
return 'Vectox['+ label + ']';
};
return {
label: label,
str: _str(label)
};
};
var Edge = function(v, w){
var _str = function(v, w){
return 'Edge[' + v.str + ',' + w.str + ']';
};
return {
v : v,
w : w,
str: _str(v, w)
};
};
var Graph = function(vs) {
var es = {};
var _str = function(es){
console.log(es);
};
return {
vs: vs,
es: {},
add_edge: function(v, w) {
var e = Edge(v, w);
this.es[v] = {w: e};
this.es[w] = {v: e};
},
add_all_edge: function() {
for (var i=0; i < vs.length; i++){
for (var j=i+1; j < vs.length; j++){
this.add_edge(vs[i], vs[j]);
}
}
},
str: ,
};
};
var init = function(){
v = Vertox('v');
w = Vertox('w');
e = Edge(v, w);
g = Graph([v, w]);
g.add_all_edge();
console.log(g.str);
};
init();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment