Created
October 9, 2015 12:09
-
-
Save dz1984/dad3faa8e98e98b9ee89 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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