@@ -29,8 +29,43 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
2929 }
3030 } ) ;
3131 } ,
32- _setData : function ( G ) {
33- if ( Tracer . prototype . _setData . call ( this , arguments ) ) return true ;
32+ _weight : function ( target , weight , delay ) {
33+ tm . pushStep ( this . capsule , { type : 'weight' , target : target , weight : weight } , delay ) ;
34+ } ,
35+ _visit : function ( target , source , weight ) {
36+ tm . pushStep ( this . capsule , { type : 'visit' , target : target , source : source , weight : weight } ) ;
37+ } ,
38+ _leave : function ( target , source , weight ) {
39+ tm . pushStep ( this . capsule , { type : 'leave' , target : target , source : source , weight : weight } ) ;
40+ } ,
41+ processStep : function ( step , options ) {
42+ switch ( step . type ) {
43+ case 'weight' :
44+ var targetNode = this . graph . nodes ( this . n ( step . target ) ) ;
45+ if ( step . weight !== undefined ) targetNode . weight = step . weight ;
46+ break ;
47+ case 'visit' :
48+ case 'leave' :
49+ var visit = step . type == 'visit' ;
50+ var targetNode = this . graph . nodes ( this . n ( step . target ) ) ;
51+ var color = visit ? this . color . visited : this . color . left ;
52+ targetNode . color = color ;
53+ if ( step . weight !== undefined ) targetNode . weight = step . weight ;
54+ if ( step . source !== undefined ) {
55+ var edgeId = this . e ( step . source , step . target ) ;
56+ var edge = this . graph . edges ( edgeId ) ;
57+ edge . color = color ;
58+ this . graph . dropEdge ( edgeId ) . addEdge ( edge ) ;
59+ }
60+ var source = step . source ;
61+ if ( source === undefined ) source = '' ;
62+ break ;
63+ default :
64+ DirectedGraphTracer . prototype . processStep . call ( this , step , options ) ;
65+ }
66+ } ,
67+ setData : function ( G ) {
68+ if ( Tracer . prototype . setData . apply ( this , arguments ) ) return true ;
3469
3570 this . graph . clear ( ) ;
3671 var nodes = [ ] ;
@@ -76,41 +111,6 @@ WeightedDirectedGraphTracer.prototype = $.extend(true, Object.create(DirectedGra
76111
77112 return false ;
78113 } ,
79- _weight : function ( target , weight , delay ) {
80- tm . pushStep ( this . capsule , { type : 'weight' , target : target , weight : weight } , delay ) ;
81- } ,
82- _visit : function ( target , source , weight ) {
83- tm . pushStep ( this . capsule , { type : 'visit' , target : target , source : source , weight : weight } ) ;
84- } ,
85- _leave : function ( target , source , weight ) {
86- tm . pushStep ( this . capsule , { type : 'leave' , target : target , source : source , weight : weight } ) ;
87- } ,
88- processStep : function ( step , options ) {
89- switch ( step . type ) {
90- case 'weight' :
91- var targetNode = this . graph . nodes ( this . n ( step . target ) ) ;
92- if ( step . weight !== undefined ) targetNode . weight = step . weight ;
93- break ;
94- case 'visit' :
95- case 'leave' :
96- var visit = step . type == 'visit' ;
97- var targetNode = this . graph . nodes ( this . n ( step . target ) ) ;
98- var color = visit ? this . color . visited : this . color . left ;
99- targetNode . color = color ;
100- if ( step . weight !== undefined ) targetNode . weight = step . weight ;
101- if ( step . source !== undefined ) {
102- var edgeId = this . e ( step . source , step . target ) ;
103- var edge = this . graph . edges ( edgeId ) ;
104- edge . color = color ;
105- this . graph . dropEdge ( edgeId ) . addEdge ( edge ) ;
106- }
107- var source = step . source ;
108- if ( source === undefined ) source = '' ;
109- break ;
110- default :
111- DirectedGraphTracer . prototype . processStep . call ( this , step , options ) ;
112- }
113- } ,
114114 clear : function ( ) {
115115 DirectedGraphTracer . prototype . clear . call ( this ) ;
116116
0 commit comments