Skip to content

Commit 30daf17

Browse files
committed
rename Graph to DirectedGraph, and WeightedGraph to WeightedDirectedGraph
1 parent 425f421 commit 30daf17

File tree

9 files changed

+39
-39
lines changed

9 files changed

+39
-39
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var tracer = new WeightedGraphTracer();
1+
var tracer = new WeightedDirectedGraphTracer();
22
/*var G = [ // G[i][j] indicates the weight of the path from the i-th node to the j-th node
33
[0, 3, 0, 1, 0],
44
[5, 0, 1, 2, 4],
55
[1, 0, 0, 2, 0],
66
[0, 2, 0, 0, 1],
77
[0, 1, 3, 0, 0]
88
];*/
9-
var G = WeightedGraph.random(10, .3, 1, 9);
9+
var G = WeightedDirectedGraph.random(10, .3, 1, 9);
1010
tracer._setData(G);

algorithm/graph_search/bfs/tree/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var tracer = new GraphTracer();
1+
var tracer = new DirectedGraphTracer();
22
var G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
33
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
44
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var tracer = new GraphTracer();
1+
var tracer = new DirectedGraphTracer();
22
/*var G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
33
[0, 1, 1, 1, 0],
44
[0, 0, 1, 1, 1],
55
[0, 0, 0, 0, 0],
66
[0, 0, 0, 0, 1],
77
[0, 0, 0, 0, 0]
88
];*/
9-
var G = Graph.random(5, .75);
9+
var G = DirectedGraph.random(5, .75);
1010
tracer._setData(G);
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var tracer = new WeightedGraphTracer();
1+
var tracer = new WeightedDirectedGraphTracer();
22
/*var G = [ // G[i][j] indicates the weight of the path from the i-th node to the j-th node
33
[0, 3, 0, 1, 0],
44
[5, 0, 1, 2, 4],
55
[1, 0, 0, 2, 0],
66
[0, 2, 0, 0, 1],
77
[0, 1, 3, 0, 0]
88
];*/
9-
var G = WeightedGraph.random(10, .3, 1, 9);
9+
var G = WeightedDirectedGraph.random(10, .3, 1, 9);
1010
tracer._setData(G);

algorithm/graph_search/dfs/tree/data.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var tracer = new GraphTracer();
1+
var tracer = new DirectedGraphTracer();
22
var G = [ // G[i][j] indicates whether the path from the i-th node to the j-th node exists or not
33
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
44
[0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0],
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
var tracer = new WeightedGraphTracer();
1+
var tracer = new WeightedDirectedGraphTracer();
22
/*var G = [ // G[i][j] indicates the weight of the path from the i-th node to the j-th node
33
[0, 3, 0, 1, 0],
44
[5, 0, 1, 2, 4],
55
[1, 0, 0, 2, 0],
66
[0, 2, 0, 0, 1],
77
[0, 1, 3, 0, 0]
88
];*/
9-
var G = WeightedGraph.random(5, .5);
9+
var G = WeightedDirectedGraph.random(5, .5);
1010
tracer._setData(G);

index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ <h3>Reference</h3>
108108
<script src="js/sigma/plugins/sigma.plugins.dragNodes.min.js"></script>
109109
<script src="js/ace/ace.js"></script>
110110
<script src="js/module/tracer.js"></script>
111-
<script src="js/module/graph.js"></script>
112-
<script src="js/module/weighted_graph.js"></script>
111+
<script src="js/module/directed_graph.js"></script>
112+
<script src="js/module/directed_weighted_graph.js"></script>
113113
<script src="js/module/array2d.js"></script>
114114
<script src="js/module/array1d.js"></script>
115115
<script src="js/script.js"></script>

js/module/graph.js renamed to js/module/directed_graph.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
var s = null, graph = null, sigmaCanvas = null;
22

3-
function GraphTracer(module) {
4-
if (Tracer.call(this, module || GraphTracer)) {
3+
function DirectedGraphTracer(module) {
4+
if (Tracer.call(this, module || DirectedGraphTracer)) {
55
initGraph();
66
return true;
77
}
88
return false;
99
}
1010

11-
GraphTracer.prototype = Object.create(Tracer.prototype);
12-
GraphTracer.prototype.constructor = GraphTracer;
11+
DirectedGraphTracer.prototype = Object.create(Tracer.prototype);
12+
DirectedGraphTracer.prototype.constructor = DirectedGraphTracer;
1313

1414
// Override
15-
GraphTracer.prototype.resize = function () {
15+
DirectedGraphTracer.prototype.resize = function () {
1616
Tracer.prototype.resize.call(this);
1717

1818
this.refresh();
1919
};
2020

2121
// Override
22-
GraphTracer.prototype.clear = function () {
22+
DirectedGraphTracer.prototype.clear = function () {
2323
Tracer.prototype.clear.call(this);
2424

2525
clearGraphColor();
2626
};
2727

28-
var Graph = {
28+
var DirectedGraph = {
2929
random: function (N, ratio) {
3030
if (!N) N = 5;
3131
if (!ratio) ratio = .3;
@@ -41,7 +41,7 @@ var Graph = {
4141
}
4242
};
4343

44-
GraphTracer.prototype._setTreeData = function (G, root) {
44+
DirectedGraphTracer.prototype._setTreeData = function (G, root) {
4545
root = root || 0;
4646
var maxDepth = -1;
4747

@@ -84,7 +84,7 @@ GraphTracer.prototype._setTreeData = function (G, root) {
8484
};
8585

8686
// Override
87-
GraphTracer.prototype._setData = function (G) {
87+
DirectedGraphTracer.prototype._setData = function (G) {
8888
if (Tracer.prototype._setData.call(this, arguments)) return true;
8989

9090
graph.clear();
@@ -130,15 +130,15 @@ GraphTracer.prototype._setData = function (G) {
130130
return false;
131131
};
132132

133-
GraphTracer.prototype._visit = function (target, source) {
133+
DirectedGraphTracer.prototype._visit = function (target, source) {
134134
this.pushStep({type: 'visit', target: target, source: source}, true);
135135
};
136136

137-
GraphTracer.prototype._leave = function (target, source) {
137+
DirectedGraphTracer.prototype._leave = function (target, source) {
138138
this.pushStep({type: 'leave', target: target, source: source}, true);
139139
};
140140

141-
GraphTracer.prototype.processStep = function (step, options) {
141+
DirectedGraphTracer.prototype.processStep = function (step, options) {
142142
switch (step.type) {
143143
case 'visit':
144144
case 'leave':
@@ -160,14 +160,14 @@ GraphTracer.prototype.processStep = function (step, options) {
160160
};
161161

162162
// Override
163-
GraphTracer.prototype.refresh = function () {
163+
DirectedGraphTracer.prototype.refresh = function () {
164164
Tracer.prototype.refresh.call(this);
165165

166166
s.refresh();
167167
};
168168

169169
// Override
170-
GraphTracer.prototype.prevStep = function () {
170+
DirectedGraphTracer.prototype.prevStep = function () {
171171
this.clear();
172172
$('#tab_trace .wrapper').empty();
173173
var finalIndex = this.traceIndex - 1;

js/module/weighted_graph.js renamed to js/module/directed_weighted_graph.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
function WeightedGraphTracer(module) {
2-
if (GraphTracer.call(this, module || WeightedGraphTracer)) {
1+
function WeightedDirectedGraphTracer(module) {
2+
if (DirectedGraphTracer.call(this, module || WeightedDirectedGraphTracer)) {
33
initWeightedGraph();
44
return true;
55
}
66
return false;
77
}
88

9-
WeightedGraphTracer.prototype = Object.create(GraphTracer.prototype);
10-
WeightedGraphTracer.prototype.constructor = WeightedGraphTracer;
9+
WeightedDirectedGraphTracer.prototype = Object.create(DirectedGraphTracer.prototype);
10+
WeightedDirectedGraphTracer.prototype.constructor = WeightedDirectedGraphTracer;
1111

1212
// Override
13-
WeightedGraphTracer.prototype.clear = function () {
14-
GraphTracer.prototype.clear.call(this);
13+
WeightedDirectedGraphTracer.prototype.clear = function () {
14+
DirectedGraphTracer.prototype.clear.call(this);
1515

1616
clearWeights();
1717
};
1818

19-
var WeightedGraph = {
19+
var WeightedDirectedGraph = {
2020
random: function (N, ratio, min, max) {
2121
if (!N) N = 5;
2222
if (!ratio) ratio = .3;
@@ -39,7 +39,7 @@ var WeightedGraph = {
3939
};
4040

4141
// Override
42-
WeightedGraphTracer.prototype._setData = function (G) {
42+
WeightedDirectedGraphTracer.prototype._setData = function (G) {
4343
if (Tracer.prototype._setData.call(this, arguments)) return true;
4444

4545
graph.clear();
@@ -87,20 +87,20 @@ WeightedGraphTracer.prototype._setData = function (G) {
8787
return false;
8888
};
8989

90-
GraphTracer.prototype._weight = function (target, weight, delay) {
90+
DirectedGraphTracer.prototype._weight = function (target, weight, delay) {
9191
this.pushStep({type: 'weight', target: target, weight: weight}, delay);
9292
};
9393

94-
GraphTracer.prototype._visit = function (target, source, weight) {
94+
DirectedGraphTracer.prototype._visit = function (target, source, weight) {
9595
this.pushStep({type: 'visit', target: target, source: source, weight: weight}, true);
9696
};
9797

98-
GraphTracer.prototype._leave = function (target, source, weight) {
98+
DirectedGraphTracer.prototype._leave = function (target, source, weight) {
9999
this.pushStep({type: 'leave', target: target, source: source, weight: weight}, true);
100100
};
101101

102102
//Override
103-
WeightedGraphTracer.prototype.processStep = function (step, options) {
103+
WeightedDirectedGraphTracer.prototype.processStep = function (step, options) {
104104
switch (step.type) {
105105
case 'weight':
106106
var targetNode = graph.nodes(n(step.target));
@@ -124,7 +124,7 @@ WeightedGraphTracer.prototype.processStep = function (step, options) {
124124
printTrace(visit ? source + ' -> ' + step.target : source + ' <- ' + step.target);
125125
break;
126126
default:
127-
GraphTracer.prototype.processStep.call(this, step, options);
127+
DirectedGraphTracer.prototype.processStep.call(this, step, options);
128128
}
129129
};
130130

0 commit comments

Comments
 (0)