Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (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();
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement