@@ -52,6 +52,7 @@ Drawing.SimpleGraph = function(options) {
52
52
var options = options || { } ;
53
53
54
54
this . layout = options . layout || "2d" ;
55
+ this . layout_options = options . graphLayout || { } ;
55
56
this . show_stats = options . showStats || false ;
56
57
this . show_info = options . showInfo || false ;
57
58
this . selection = options . selection || false ;
@@ -143,6 +144,7 @@ Drawing.SimpleGraph = function(options) {
143
144
}
144
145
145
146
function createGraph ( ) {
147
+
146
148
var node = new Node ( 0 ) ;
147
149
graph . addNode ( node ) ;
148
150
drawNode ( node ) ;
@@ -167,13 +169,82 @@ Drawing.SimpleGraph = function(options) {
167
169
}
168
170
steps ++ ;
169
171
}
170
-
171
- graph . layout = new Layout . ForceDirected ( graph , { width : 2000 , height : 2000 , iterations : 1000 , layout : that . layout } ) ;
172
+
173
+ that . layout_options . width = that . layout_options . width || 2000 ;
174
+ that . layout_options . height = that . layout_options . height || 2000 ;
175
+ that . layout_options . iterations = that . layout_options . iterations || 100000 ;
176
+ that . layout_options . layout = that . layout_options . layout || that . layout ;
177
+ graph . layout = new Layout . ForceDirected ( graph , that . layout_options ) ;
172
178
graph . layout . init ( ) ;
173
179
info_text . nodes = "Nodes " + graph . nodes . length ;
174
180
info_text . edges = "Edges " + graph . edges . length ;
175
181
}
176
182
183
+ // for testing...
184
+ // function createCube() {
185
+ //
186
+ // var a1 = new Node("a1");
187
+ // graph.addNode(a1);
188
+ // drawNode(a1);
189
+ //
190
+ // var a2 = new Node("a2");
191
+ // graph.addNode(a2);
192
+ // drawNode(a2);
193
+ // var a3 = new Node("a3");
194
+ // graph.addNode(a3);
195
+ // drawNode(a3);
196
+ // var a4 = new Node("a4");
197
+ // graph.addNode(a4);
198
+ // drawNode(a4);
199
+ // var b1 = new Node("b1");
200
+ // graph.addNode(b1);
201
+ // drawNode(b1);
202
+ // var b2 = new Node("b2");
203
+ // graph.addNode(b2);
204
+ // drawNode(b2);
205
+ // var b3 = new Node("b3");
206
+ // graph.addNode(b3);
207
+ // drawNode(b3);
208
+ // var b4 = new Node("b4");
209
+ // graph.addNode(b4);
210
+ // drawNode(b4);
211
+ //
212
+ // graph.addEdge(a1, a2);
213
+ // drawEdge(a1, a2);
214
+ // graph.addEdge(a1, a4);
215
+ // drawEdge(a1, a4);
216
+ // graph.addEdge(a1, b1);
217
+ // drawEdge(a1, b1);
218
+ //
219
+ // graph.addEdge(a2, a3);
220
+ // drawEdge(a2, a3);
221
+ // graph.addEdge(a2, b2);
222
+ // drawEdge(a2, b2);
223
+ //
224
+ // graph.addEdge(a3, a4);
225
+ // drawEdge(a3, a4);
226
+ // graph.addEdge(a3, b3);
227
+ // drawEdge(a3, b3);
228
+ //
229
+ // graph.addEdge(a4, b4);
230
+ // drawEdge(a4, b4);
231
+ //
232
+ // graph.addEdge(b1, b2);
233
+ // drawEdge(b1, b2);
234
+ // graph.addEdge(b1, b4);
235
+ // drawEdge(b1, b4);
236
+ //
237
+ // graph.addEdge(b2, b3);
238
+ // drawEdge(b2, b3);
239
+ // graph.addEdge(b3, b4);
240
+ // drawEdge(b3, b4);
241
+ //
242
+ //
243
+ // graph.layout = new Layout.ForceDirected(graph, {width: 2000, height: 2000, iterations: 10000, layout: that.layout});
244
+ // graph.layout.init();
245
+ // info_text.nodes = "Nodes " + graph.nodes.length;
246
+ // info_text.edges = "Edges " + graph.edges.length;
247
+ // }
177
248
178
249
179
250
function drawNode ( node ) {
@@ -194,7 +265,7 @@ Drawing.SimpleGraph = function(options) {
194
265
// var xm = new THREE.MeshBasicMaterial( { map: new THREE.Texture( labelCanvas ), transparent: true } );
195
266
// xm.map.needsUpdate = true;
196
267
197
- var area = 2000 ;
268
+ var area = 5000 ;
198
269
draw_object . position . x = Math . floor ( Math . random ( ) * ( area + area + 1 ) - area ) ;
199
270
draw_object . position . y = Math . floor ( Math . random ( ) * ( area + area + 1 ) - area ) ;
200
271
0 commit comments