[go: up one dir, main page]

Menu

[131a93]: / scripts / Main.py  Maximize  Restore  History

Download this file

874 lines (666 with data), 34.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
# AUTOMATICALLY GENERATED
# Defines wrapper methods that can be used as shortcuts in the interpreter
from com.hp.hpl.guess import Guess
from com.hp.hpl.guess.piccolo import Arrow
from com.hp.hpl.guess.piccolo import Morpher
from com.hp.hpl.guess.util.intervals import DefaultRangeManager
def execfile(s):
interp.execfile(s)
def makeFromGDF(filename):
g.makeFromGDF(filename)
def centerAfterLayout(state):
g.centerAfterLayout(state)
def removeNodeComplete(n):
g.removeNodeComplete(n)
def initConnection(*d):
if len(d) == 1:
r.initConnection(d[0])
elif len(d) == 0:
r.initConnection()
else:
raise ValueError("Incorrect number of arguments")
def showTitle(title,time):
vf.showTitle(title,time)
def sugiyamaLayout(*d):
if len(d) == 0:
g.sugiyamaLayout()
elif len(d) == 1:
g.sugiyamaLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def getAppletContext():
return Guess.getAppletContext()
def generateColors(*d):
if len(d) == 3:
return Colors.generateColors(d[0],d[1],d[2])
elif len(d) == 4:
return Colors.generateColors(d[0],d[1],d[2],d[3])
else:
raise ValueError("Incorrect number of arguments")
def makeFromGML(filename):
g.makeFromGML(filename)
def searchOverlap(range):
return DefaultRangeManager.searchOverlap(range)
def exportPS(filename):
v.exportPS(filename)
def compressOverlapping():
g.compressOverlapping()
def exportSWF(filename):
v.exportSWF(filename)
def exportPDF(filename):
v.exportPDF(filename)
def groupBy(*d):
if len(d) == 2:
return g.groupBy(d[0],d[1])
elif len(d) == 1:
return g.groupBy(d[0])
else:
raise ValueError("Incorrect number of arguments")
def jSpringLayout(*d):
if len(d) == 0:
g.jSpringLayout()
elif len(d) == 1:
g.jSpringLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setDisplayBackground(c):
v.setDisplayBackground(c)
def setNodeDisappearBy(nodeDisBy):
Morpher.setNodeDisappearBy(nodeDisBy)
def gemLayout(*d):
if len(d) == 0:
g.gemLayout()
elif len(d) == 1:
g.gemLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setTitleColor(aColor):
vf.setTitleColor(aColor)
def averageColor(c1,c2):
return Colors.averageColor(c1,c2)
def makeErdosRenyiRandom(nodes,p):
g.makeErdosRenyiRandom(nodes,p)
def ls(*d):
if len(d) == 2:
db.loadState(d[0],d[1])
elif len(d) == 1:
db.loadState(d[0])
else:
raise ValueError("Incorrect number of arguments")
def exportGDF(filename):
g.exportGDF(filename)
def getNodeAppearAfter():
return Morpher.getNodeAppearAfter()
def weightedKKLayout(*d):
if len(d) == 0:
g.weightedKKLayout()
elif len(d) == 1:
g.weightedKKLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def removeEdgeComplete(e):
g.removeEdgeComplete(e)
def kkLayout(*d):
if len(d) == 0:
g.kkLayout()
elif len(d) == 1:
g.kkLayout(d[0])
elif len(d) == 2:
g.kkLayout(d[0],d[1])
elif len(d) == 3:
g.kkLayout(d[0],d[1],d[2])
else:
raise ValueError("Incorrect number of arguments")
def addNodeField(fieldName,sqlType,defaultValue):
return g.addNodeField(fieldName,sqlType,defaultValue)
def exportCGM(filename):
v.exportCGM(filename)
def createConvexHull(seq,c):
return vf.createConvexHull(seq,c)
def isRConnected():
return r.isConnected()
def mdsLayout():
g.mdsLayout()
def makeLattice1DRandom(nodes,tor):
g.makeLattice1DRandom(nodes,tor)
def removeComplete(seq):
g.removeComplete(seq)
def setEdgeAppearAfter(edgeAppearAfter):
Morpher.setEdgeAppearAfter(edgeAppearAfter)
def makeFromDL(filename):
g.makeFromDL(filename)
def remove(seq):
return g.remove(seq)
def removeEdge(e):
return g.removeEdge(e)
def getNodeSchema():
return g.getNodeSchema()
def getEdgeDisappearBy():
return Morpher.getEdgeDisappearBy()
def addRange(o,range):
DefaultRangeManager.addRange(o,range)
def stopMovie():
v.stopMovie()
def addEdge(node1,node2):
return g.addEdge(node1,node2)
def getMTF():
return Guess.getMTF()
def getSynchronous():
return Guess.getSynchronous()
def setBackgroundImage(*d):
if len(d) == 1:
v.setBackgroundImage(d[0])
elif len(d) == 3:
v.setBackgroundImage(d[0],d[1],d[2])
else:
raise ValueError("Incorrect number of arguments")
def jkkLayout1(*d):
if len(d) == 0:
g.jkkLayout1()
elif len(d) == 1:
g.jkkLayout1(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setNodeAppearAfter(nodeAppearAfter):
Morpher.setNodeAppearAfter(nodeAppearAfter)
def removeDisconnected():
return g.removeDisconnected()
def dagLayout():
g.dagLayout()
def expandOverlapping():
g.expandOverlapping()
def dragwindow():
DragWindow.create()
def getEdgeAppearAfter():
return Morpher.getEdgeAppearAfter()
def stoplog():
interp.stoplog()
def setMTF(state):
Guess.setMTF(state)
def add(seq):
g.add(seq)
def drawwindow():
DrawWindow.create()
def removeNode(n):
return g.removeNode(n)
def hideDisconnected():
g.hideDisconnected()
def getDirected():
return vf.getDirected()
def springLayout(*d):
if len(d) == 0:
g.springLayout()
elif len(d) == 1:
g.springLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setDirected(dir):
vf.setDirected(dir)
def jfrLayout():
g.jfrLayout()
def setPageRankBias(bias):
g.setPageRankBias(bias)
def setFrozen(state):
v.setFrozen(state)
def makeEppsteinRandom(nodes,edges,r):
g.makeEppsteinRandom(nodes,edges,r)
def circleLayout(*d):
if len(d) == 0:
g.circleLayout()
elif len(d) == 2:
g.circleLayout(d[0],d[1])
elif len(d) == 4:
g.circleLayout(d[0],d[1],d[2],d[3])
else:
raise ValueError("Incorrect number of arguments")
def weakComponentClusters():
return g.weakComponentClusters()
def rshutdown():
r.shutdown()
def translateLayout(newX,newY):
g.translateLayout(newX,newY)
def removeBackgroundImage():
v.removeBackgroundImage()
def getSubgraph(name):
return Subgraph.getRootSubgraph(name)
def groupAndSortBy(*d):
if len(d) == 1:
return g.groupAndSortBy(d[0])
elif len(d) == 2:
return g.groupAndSortBy(d[0],d[1])
else:
raise ValueError("Incorrect number of arguments")
def searchContained(range):
return DefaultRangeManager.searchContained(range)
def physicsLayout(*d):
if len(d) == 0:
g.physicsLayout()
elif len(d) == 1:
g.physicsLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def getGraphMap():
return r.getGraphMap()
def sortBy(*d):
if len(d) == 2:
return g.sortBy(d[0],d[1])
elif len(d) == 1:
return g.sortBy(d[0])
else:
raise ValueError("Incorrect number of arguments")
def reval(s):
return r.evalString(s)
def removeConvexHulls(seq):
vf.removeConvexHulls(seq)
def randomLayout(*d):
if len(d) == 0:
g.randomLayout()
elif len(d) == 2:
g.randomLayout(d[0],d[1])
else:
raise ValueError("Incorrect number of arguments")
def randomColor(*d):
if len(d) == 0:
return Colors.randomColor()
elif len(d) == 1:
return Colors.randomColor(d[0])
else:
raise ValueError("Incorrect number of arguments")
def moveLayout(newX,newY):
g.moveLayout(newX,newY)
def sql(expression):
db.q(expression)
def morph(state,duration):
g.morph(state,duration)
def makeSimpleDirectedRandom(nodes,edges):
g.makeSimpleDirectedRandom(nodes,edges)
def exportJPG(filename):
v.exportJPG(filename)
def radialLayout(center):
g.radialLayout(center)
def density():
return g.density()
def overrideArrowLength(length):
Arrow.overrideArrowLength(length)
def rescaleLayout(*d):
if len(d) == 2:
g.rescaleLayout(d[0],d[1])
elif len(d) == 1:
g.rescaleLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setSynchronous(state):
Guess.setSynchronous(state)
def weightedSpringLayout(*d):
if len(d) == 2:
g.weightedSpringLayout(d[0],d[1])
elif len(d) == 3:
g.weightedSpringLayout(d[0],d[1],d[2])
else:
raise ValueError("Incorrect number of arguments")
def resizeLinear(f,start,end):
g.resizeLinear(f,start,end)
def exportGIF(filename):
v.exportGIF(filename)
def binPackLayout(*d):
if len(d) == 0:
g.binPackLayout()
elif len(d) == 1:
g.binPackLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def getJythonConsole():
return Guess.getJythonConsole()
def colorize(*d):
if len(d) == 1:
g.colorize(d[0])
elif len(d) == 3:
g.colorize(d[0],d[1],d[2])
elif len(d) == 4:
g.colorize(d[0],d[1],d[2],d[3])
else:
raise ValueError("Incorrect number of arguments")
def frLayout(*d):
if len(d) == 0:
g.frLayout()
elif len(d) == 2:
g.frLayout(d[0],d[1])
else:
raise ValueError("Incorrect number of arguments")
def setEdgeDisappearBy(edgeDisBy):
Morpher.setEdgeDisappearBy(edgeDisBy)
def infowindow(*d):
if len(d) == 0:
InfoWindow.create()
elif len(d) == 0:
SpreadSheet.create()
else:
raise ValueError("Incorrect number of arguments")
def getDisplayBackground():
return v.getDisplayBackground()
def edgeBetweennessClusters(numEdgesToRemove):
return g.edgeBetweennessClusters(numEdgesToRemove)
def exportPNG(filename):
v.exportPNG(filename)
def exportSVG(filename):
v.exportSVG(filename)
def ss(state):
db.saveState(state)
def overrideArrowWidth(width):
Arrow.overrideArrowWidth(width)
def addEdgeField(fieldName,sqlType,defaultValue):
return g.addEdgeField(fieldName,sqlType,defaultValue)
def getPageRankBias():
return g.getPageRankBias()
def resizeRandom(f,start,end):
g.resizeRandom(f,start,end)
def sugiyamaLayout2():
g.sugiyamaLayout2()
def setQuality(requestedQuality):
v.setQuality(requestedQuality)
def removeConvexHull(c):
vf.removeConvexHull(c)
def exportJAVA(filename):
v.exportJAVA(filename)
def getConvexHulls():
return vf.getConvexHulls()
def getEdgeSchema():
return g.getEdgeSchema()
def startMovie(*d):
if len(d) == 2:
v.startMovie(d[0],d[1])
elif len(d) == 3:
v.startMovie(d[0],d[1],d[2])
else:
raise ValueError("Incorrect number of arguments")
def exportEPS(filename):
v.exportEPS(filename)
def makeKleinbergRandom(nodes,clust):
g.makeKleinbergRandom(nodes,clust)
def makeBarabasiAlbertRandom(vert,edges,evolve):
g.makeBarabasiAlbertRandom(vert,edges,evolve)
def isomLayout(*d):
if len(d) == 0:
g.isomLayout()
elif len(d) == 1:
g.isomLayout(d[0])
else:
raise ValueError("Incorrect number of arguments")
def exportEMF(filename):
v.exportEMF(filename)
def makeFromPajek(filename):
g.makeFromPajek(filename)
def center(*d):
if len(d) == 0:
v.center()
elif len(d) == 1:
v.center(d[0])
else:
raise ValueError("Incorrect number of arguments")
def setRankerWeightField(f):
g.setRankerWeightField(f)
def help(tohelp):
Guess.help(tohelp)
def log(filename):
interp.log(filename)
def searchContains(range):
return DefaultRangeManager.searchContains(range)
def makeLattice2DRandom(nodes,tor):
g.makeLattice2DRandom(nodes,tor)
def readjustEdges():
g.readjustEdges()
def jkkLayout2(*d):
if len(d) == 0:
g.jkkLayout2()
elif len(d) == 1:
g.jkkLayout2(d[0])
else:
raise ValueError("Incorrect number of arguments")
def complement(seq):
return g.complement(seq)
def removeSelfLoops():
return g.removeSelfLoops()
def biComponentClusters():
return g.biComponentClusters()
def getNodeDisappearBy():
return Morpher.getNodeDisappearBy()
def searchExact(range):
return DefaultRangeManager.searchExact(range)
def makeSimpleRandom(nodes,edges):
g.makeSimpleRandom(nodes,edges)
def getStates():
return db.getStates()
__FUNCTION_DICTIONARY = {"execfile" : "void execfile(String s);\n", "makeFromGDF" : "void makeFromGDF(String filename) throws java.io.IOException \n load a graph from a GDF format file\n \tparam filename the file to load\n", "centerAfterLayout" : "void centerAfterLayout(boolean state) \n should we center after doing a layout\n disable this to control it yourself\n", "removeNodeComplete" : "void removeNodeComplete(Node n) \n removes a node completely (node, and all edges connected to it, \n will likely be unrecoverable). Removes from all states.\n \tparam n the node to remove\n", "initConnection" : "void initConnection(String server) \n\nvoid initConnection() \n", "showTitle" : "void showTitle(String title, long time) \n Shows a title in the frame\n", "sugiyamaLayout" : "void sugiyamaLayout() \n Sugiyama\n\nvoid sugiyamaLayout(boolean bends) \n Sugiyama\n", "getAppletContext" : "static AppletContext getAppletContext() \n get the applet context\n", "generateColors" : "static ArrayList<Object> generateColors(String startC, String endC, int inBetween) \n\nstatic ArrayList<Object> generateColors(String startC, String middleC, String endC, int inBetween) \n percent;\n percent;\n", "makeFromGML" : "void makeFromGML(String filename) \n load a graph from a GML file\n \tparam filename the GML filename to load\n", "searchOverlap" : "static Collection searchOverlap(String range) \n", "exportPS" : "void exportPS(String filename);\n", "compressOverlapping" : "void compressOverlapping() \n", "exportSWF" : "void exportSWF(String filename);\n", "exportPDF" : "void exportPDF(String filename);\n", "groupBy" : "Collection<SortableHashSet> groupBy(PySequence seq, Field field) \n genererates a set of sets grouped by some field that defined equivalence\n \tparam seq the thing to group by\n \tparam field the field to sort by\n\nCollection<SortableHashSet> groupBy(Field field) \n generates a set of sets on all graph objects, guesses type by field\n \tparam field the field that defined equivalence\n", "jSpringLayout" : "void jSpringLayout() \n the JUNG Spring Layout (seems a little broken). Asks\n every 30 seconds if you want to keep running\n\nvoid jSpringLayout(int max) \n run the JUNG spring layout for max iterations\n \tparam max the number of iterations\n", "setDisplayBackground" : "void setDisplayBackground(Color c);\n", "setNodeDisappearBy" : "static void setNodeDisappearBy(float nodeDisBy) \n", "gemLayout" : "void gemLayout() \n GEM Layout\n\nvoid gemLayout(long seed) \n GEM Layout\n \tparam seed the seed for the random number generator, useful\n for getting the same layout every time.\n", "setTitleColor" : "void setTitleColor(Color aColor) \n Sets the Color of the title text\n", "averageColor" : "static String averageColor(String c1, String c2) \n", "makeErdosRenyiRandom" : "void makeErdosRenyiRandom(int nodes, double p) \n", "ls" : "void loadState(Graph g, int state);\n\nvoid loadState(String state);\n", "exportGDF" : "void exportGDF(String filename) \n generate a GDF representation of the file\n \tparam filename the filename to output\n", "getNodeAppearAfter" : "static float getNodeAppearAfter() \n", "weightedKKLayout" : "void weightedKKLayout() \n a weighted JUNG Kamada-Kawai (regular)\n\nvoid weightedKKLayout(int iters) \n a weighted JUNG Kamada-Kawai (regular) with user defined iterations\n \tparam iters\n", "removeEdgeComplete" : "void removeEdgeComplete(Edge e) \n removes an edge completely. Removes from all states.\n \tparam e the node to remove\n", "kkLayout" : "void kkLayout() \n Kamada-Kawai, puts nodes in 1000 x 1000 square\n\nvoid kkLayout(int passes) \n Kamada-Kawai, puts nodes in 1000 x 1000 square\n \tparam passes\n\nvoid kkLayout(int width, int height) \n Kamada-Kawai into a width x height grid\n \tparam width\n \tparam height\n\nvoid kkLayout(int width, int height, int passes) \n Kamada-Kawai into a width x height grid and some number of iterations\n \tparam width\n \tparam height\n \tparam passes\n", "addNodeField" : "Field addNodeField(String fieldName, int sqlType, Object defaultValue) \n Create a new node field\n \tparam fieldname the name of the field\n \tparam sqlType the type of the node (see java.sql)\n \tparam defaultValue the default this field should take\n", "exportCGM" : "void exportCGM(String filename);\n", "createConvexHull" : "ConvexHull createConvexHull(PySequence seq, String c) \n", "isRConnected" : "boolean isConnected() \n", "mdsLayout" : "void mdsLayout() \n Multidimensional scaling layout based on edge weight\n", "makeLattice1DRandom" : "void makeLattice1DRandom(int nodes, boolean tor) \n", "removeComplete" : "void removeComplete(PySequence seq) \n remove nodes and edges completely from the system (all states)\n \tparam seq the nodes + edges\n", "setEdgeAppearAfter" : "static void setEdgeAppearAfter(float edgeAppearAfter) \n", "makeFromDL" : "void makeFromDL(String filename) \n", "remove" : "Set remove(PySequence seq) \n remove nodes and edges from the graph\n \tparam seq the nodes + edges\n", "removeEdge" : "Set<AbstractElement> removeEdge(Edge e) \n remove an edge from the graph\n \tparam e the edge to remove\n", "getNodeSchema" : "NodeSchema getNodeSchema() \n grab the node schema\n", "getEdgeDisappearBy" : "static float getEdgeDisappearBy() \n", "addRange" : "static void addRange(Object o, String range) \n", "stopMovie" : "void stopMovie() \n basically dumps the movie to disk\n", "addEdge" : "UndirectedEdge addEdge(Node node1, Node node2) \n user's API shortcut for adding a new undirected edge.\n", "getMTF" : "static boolean getMTF() \n Are objects being moved to the front when they change\n", "getSynchronous" : "static boolean getSynchronous() \n thread management\n", "setBackgroundImage" : "void setBackgroundImage(String filename);\n\nvoid setBackgroundImage(String filename, double x, double y);\n", "jkkLayout1" : "void jkkLayout1() \n the JUNG Kamada-Kawai (regular)\n\nvoid jkkLayout1(int iters) \n the JUNG Kamada-Kawai (regular) with user defined iterations\n \tparam iters\n", "setNodeAppearAfter" : "static void setNodeAppearAfter(float nodeAppearAfter) \n", "removeDisconnected" : "Set removeDisconnected() \n removes disconnected nodes\n", "dagLayout" : "void dagLayout() \n DAG\n", "expandOverlapping" : "void expandOverlapping() \n", "dragwindow" : "static void create() \n", "getEdgeAppearAfter" : "static float getEdgeAppearAfter() \n", "stoplog" : "void stoplog();\n", "setMTF" : "static void setMTF(boolean state) \n should objects in the visualization be moved to the front\n when they change\n", "add" : "void add(PySequence seq) \n add nodes and edges from the graph\n \tparam seq the nodes + edges\n", "drawwindow" : "static void create() \n", "removeNode" : "Set<AbstractElement> removeNode(Node n) \n remove a node from the graph\n \tparam n the node to remove\n", "hideDisconnected" : "void hideDisconnected() \n hides disconnected nodes\n", "getDirected" : "boolean getDirected() \n", "springLayout" : "void springLayout() \n spring layout, runs for 30 seconds and asks if you want\n to continue\n\nvoid springLayout(int max) \n spring layout for max iterations\n \tparam max number of iterations\n", "setDirected" : "void setDirected(boolean dir) \n", "jfrLayout" : "void jfrLayout() \n the JUNG Fructerman-Rheingold Layout\n", "setPageRankBias" : "void setPageRankBias(double bias) \n sets the page rank bias\n \tparam bias the bias\n", "setFrozen" : "void setFrozen(boolean state);\n", "makeEppsteinRandom" : "void makeEppsteinRandom(int nodes, int edges, int r) \n", "circleLayout" : "void circleLayout() \n places all nodes in a circle\n\nvoid circleLayout(Field f, Node c) \n places all nodes in a circle with node c in the middle\n and its neighbors around that center with a radius\n proportional to field f (all nodes that are not neighbors\n of c will be left as is)\n \tparam f the field to use to calc the radius\n \tparam c the node to put in the center\n\nvoid circleLayout(Field f, Node c, double xorigin, double yorigin) \n places all nodes in a circle with node c in the middle\n and its neighbors around that center with a radius\n proportional to field f (all nodes that are not neighbors\n of c will be left as is)\n \tparam f the field to use to calc the radius\n \tparam c the node to put in the center\n \tparam xorigin the x location for the center node\n \tparam yorigin the y location for the center node\n", "weakComponentClusters" : "Set weakComponentClusters() \n do weak component clustering\n \treturn a set of sets\n", "rshutdown" : "void shutdown() throws Exception \n", "translateLayout" : "void translateLayout(int newX, int newY) \n moves the nodes to a new origin\n \tparam newX\n \tparam newY\n", "removeBackgroundImage" : "void removeBackgroundImage();\n", "getSubgraph" : "static Subgraph getRootSubgraph(String name) \n", "groupAndSortBy" : "Collection<SortableHashSet> groupAndSortBy(Field field) \n simulatenous sort and group\n \tparam field the field to group and sort by\n\nCollection groupAndSortBy(PySequence seq, Field field) \n simulatenous group annd sort\n \tparam seq the set to group and sort\n \tparam field the field\n", "searchContained" : "static Collection searchContained(String range) \n", "physicsLayout" : "void physicsLayout() \n physics layout, asks every 30 seconds if you want to keep running\n\nvoid physicsLayout(int max) \n run physics layout for max steps\n \tparam max the number of steps\n", "getGraphMap" : "GraphMap getGraphMap() \n", "sortBy" : "Collection<GraphElement> sortBy(PySequence seq, Field field) \n sort some set by some field\n \tparam seq the set to sort\n \tparam field the field to sort by\n\nCollection<GraphElement> sortBy(Field field) \n sort all graph elements by some field, guesses a the type\n of object you want to sort by based on the field type\n \tparam field the field to sort by\n", "reval" : "Object evalString(String s) \n", "removeConvexHulls" : "void removeConvexHulls(PySequence seq) \n", "randomLayout" : "void randomLayout() \n randomly places nodes in a 1000 x 1000 grid\n\nvoid randomLayout(int width, int height) \n randomly places nodes in a width x height grid\n \tparam width width\n \tparam height height\n", "randomColor" : "static String randomColor() \n\nstatic String randomColor(int alpha) \n", "moveLayout" : "void moveLayout(int newX, int newY) \n moves the nodes to a new origin\n \tparam newX\n \tparam newY\n", "sql" : "synchronized void q(String expression) throws SQLException \n", "morph" : "void morph(String state, long duration) \n morph from the current state to some other state over a time\n \tparam state the state to morph to \n \tparam duration the time to morph over\n", "makeSimpleDirectedRandom" : "void makeSimpleDirectedRandom(int nodes, int edges) \n make a random directed graph\n \tparam nodes the number of nodes\n \tparam edges the number of edges\n", "exportJPG" : "void exportJPG(String filename);\n", "radialLayout" : "void radialLayout(Node center) \n places all nodes in a growing radius around center\n \tparam center the node to put in the center\n", "density" : "double density() \n calculate the graph density\n", "overrideArrowLength" : "static void overrideArrowLength(int length) \n", "rescaleLayout" : "void rescaleLayout(int width, int height) \n rescales nodes to fit into width x height\n \tparam width the rescale width\n \tparam height the rescale height\n\nvoid rescaleLayout(double percent) \n rescales the layout to %percent\n \tparam percent the percent to shrink/grow\n", "setSynchronous" : "static void setSynchronous(boolean state) \n should layouts run in their own threads?\n", "weightedSpringLayout" : "void weightedSpringLayout(int min, int max) \n spring layout, runs for 30 seconds and asks if you want\n to continue\n\nvoid weightedSpringLayout(int minL, int maxL, int max) \n spring layout for max iterations\n \tparam max number of iterations\n", "resizeLinear" : "void resizeLinear(Field f, double start, double end) \n", "exportGIF" : "void exportGIF(String filename);\n", "binPackLayout" : "void binPackLayout() \n packs all nodes\n\nvoid binPackLayout(boolean rescale) \n packs all nodes\n", "getJythonConsole" : "static TextPaneJythonConsole getJythonConsole() \n gets a reference to the existing GUI console object, or\n null if it doesn't exist\n", "colorize" : "void colorize(Field f) \n color nodes or edges by some field, nodes/edges with\n equal field values take on the same (randomly chosen) color\n \tparam f the field to color by\n\nvoid colorize(Field f, Color start, Color end) \n\nvoid colorize(Field f, Color start, Color middle, Color end) \n", "frLayout" : "void frLayout() \n Fruchterman-Rheingold, puts nodes in 1000 x 1000 square\n\nvoid frLayout(int width, int height) \n Fruchterman-Rheingold into a width x height grid\n \tparam width\n \tparam height\n", "setEdgeDisappearBy" : "static void setEdgeDisappearBy(float edgeDisBy) \n", "infowindow" : "static void create() \n\nstatic void create() \n", "getDisplayBackground" : "Color getDisplayBackground();\n", "edgeBetweennessClusters" : "Set edgeBetweennessClusters(int numEdgesToRemove) \n do Edge betweenness clustering\n \tparam numEdgesToRemove edges to remove\n \treturn a set of sets\n", "exportPNG" : "void exportPNG(String filename);\n", "exportSVG" : "void exportSVG(String filename);\n", "ss" : "void saveState(int state);\n", "overrideArrowWidth" : "static void overrideArrowWidth(int width) \n", "addEdgeField" : "Field addEdgeField(String fieldName, int sqlType, Object defaultValue) \n Create a new edge field\n \tparam fieldname the name of the field\n \tparam sqlType the type of the node (see java.sql)\n \tparam defaultValue the default this field should take\n", "getPageRankBias" : "double getPageRankBias() \n returne the pagerank bias\n", "resizeRandom" : "void resizeRandom(Field f, double start, double end) \n", "sugiyamaLayout2" : "void sugiyamaLayout2() \n Sugiyama\n", "setQuality" : "void setQuality(int requestedQuality);\n", "removeConvexHull" : "void removeConvexHull(ConvexHull c) \n", "exportJAVA" : "void exportJAVA(String filename);\n", "getConvexHulls" : "Collection<ConvexHull> getConvexHulls() \n", "getEdgeSchema" : "EdgeSchema getEdgeSchema() \n grab the edge schema\n", "startMovie" : "void startMovie(int fps, String filename) \n\nvoid startMovie(int fps, String filename, boolean auto) \n", "exportEPS" : "void exportEPS(String filename);\n", "makeKleinbergRandom" : "void makeKleinbergRandom(int nodes, double clust) \n", "makeBarabasiAlbertRandom" : "void makeBarabasiAlbertRandom(int vert, int edges, int evolve) \n", "isomLayout" : "void isomLayout() \n ISOM Layout, asks every 30 seconds if you want to continue\n\nvoid isomLayout(int max) \n ISOM Layout for max steps\n \tparam max the number of iterations\n", "exportEMF" : "void exportEMF(String filename);\n", "makeFromPajek" : "void makeFromPajek(String filename) \n load a graph from pajek\n \tparam filename the pajek file to load\n", "center" : "void center();\n\nvoid center(Object o);\n", "setRankerWeightField" : "void setRankerWeightField(Field f) \n which field to use for weighting\n \tparam f the field\n", "help" : "static void help(String tohelp) \n", "log" : "void log(String filename);\n", "searchContains" : "static Collection searchContains(String range) \n", "makeLattice2DRandom" : "void makeLattice2DRandom(int nodes, boolean tor) \n", "readjustEdges" : "void readjustEdges() \n moves edges so they don't overlap\n", "jkkLayout2" : "void jkkLayout2() \n the JUNG Kamada-Kawai (int)\n\nvoid jkkLayout2(int iters) \n the JUNG Kamada-Kawai (int) with user defined iterations\n \tparam iters\n", "complement" : "Set complement(PySequence seq) \n returns the complement (e.g. all nodes/edges in the\n graph that are not in the set). If the set contains only nodes\n only nodes will be returned. Likewise for edges. If the set contains\n both, both nodes and edges will be returned.\n \tparam seq the nodes and/or edges\n", "removeSelfLoops" : "Set removeSelfLoops() \n removes self loops\n", "biComponentClusters" : "Set biComponentClusters() \n do Bi-Component Clustering\n \treturn a set of sets\n", "getNodeDisappearBy" : "static float getNodeDisappearBy() \n", "searchExact" : "static Collection searchExact(String range) \n", "makeSimpleRandom" : "void makeSimpleRandom(int nodes, int edges) \n generate a random graph\n \tparam nodes the number of nodes\n \tparam edges the number of edges\n", "getStates" : "Set<?> getStates();\n"}
def addNode(_name,**_extra):
_temp = g.addNode(_name)
if not isinstance(_name,Class.forName("com.hp.hpl.guess.Node")):
_temp.label = _name
for _toset in _extra.keys():
_temp.__setattr__(_toset,_extra[_toset])
return _temp
def copyNode(_template,_name,**_extra):
if not isinstance(_template,Class.forName("com.hp.hpl.guess.Node")):
raise TypeError,'First argument nust be a template Node'
if not isinstance(_name,Class.forName("org.python.core.PyString")):
raise TypeError,'Second argument must be a name'
_temp = g.addNode(_name)
for _field in Node.fieldNames():
if (_field != "name"):
_temp.__setattr__(_field,_template.__getattr__(_field))
for _toset in _extra.keys():
_temp.__setattr__(_toset,_extra[_toset])
return(_temp)
def addEdge(*d,**_extra):
return addUndirectedEdge(*d,**_extra)
def addDirectedEdge(*d,**_extra):
_temp = None
if d.__len__() == 1:
_temp = g.addEdge(d[0])
elif d.__len__() == 2:
return g.addDirectedEdge(d[0],d[1])
for _toset in _extra.keys():
_temp.__setattr__(_toset,_extra[_toset])
if not _extra.has_key("label"):
_temp.label = str(_temp.weight)
return(_temp)
def addUndirectedEdge(*d,**_extra):
_temp = None
if d.__len__() == 1:
_temp = g.addEdge(d[0])
elif d.__len__() == 2:
return g.addUndirectedEdge(d[0],d[1])
for _toset in _extra.keys():
_temp.__setattr__(_toset,_extra[_toset])
if not _extra.has_key("label"):
_temp.label = str(_temp.weight)
return(_temp)
# Some demo functions that manipulate the graph in various ways
from java.lang import Math
# iteratively removes all nodes that have
# a total degree of 1
# assumes self loops have been removed
def removeLeaves():
g.nodes[0].totaldegree
_m = (totaldegree <= 1)
_toRet = []
while _m.__len__() > 0:
_toRet += remove(_m)
_m = (totaldegree <= 1)
return _toRet
# iteratively removes nodes that have an outdegree
# of introduces a new edge
# assumes self loops have been removed
def shortcutNodes():
g.nodes[0].totaldegree
_m = (totaldegree == 2)
_toRet = []
_added = []
while len(_m) > 0:
for _z in _m:
_pot = _z.getNeighbors()
if len(_pot) == 2:
if len(_pot[0]-_pot[1]) == 0:
_added += [addEdge(_pot[0],_pot[1])]
_toRet += removeNode(_z)
_m = (totaldegree == 2)
_temp = intersectionHelper(_toRet,_added)
return [_temp[0],_temp[1]]
# iteratively call removeLeaves and shortcutNodes to
# condense the graph
def condenseGraph():
_toRet = []
_added = []
_toRet += removeDisconnected()
_toRet += removeSelfLoops()
g.nodes[0].totaldegree
_t1 = (totaldegree <= 1)
_t2 = (totaldegree == 2)
while (_t1.__len__() > 0) | (_t2.__len__() > 0):
_toRet += removeLeaves()
_scr = shortcutNodes()
_toRet += _scr[0]
_added += _scr[1]
_t1 = (totaldegree <= 1)
_t2 = (totaldegree == 2)
_temp = intersectionHelper(_toRet,_added)
return [_temp[0],_temp[1]]
def intersectionHelper(_l1,_l2):
_templist = _l1 & _l2
_ln1 = []
_ln2 = []
for _elem in _l1:
if _elem not in _templist:
_ln1 += [_elem]
for _elem in _l2:
if _elem not in _templist:
_ln2 += [_elem]
return [_ln1,_ln2]
# does a "skitter" plot which lays out nodes around a circle based on the
# ordering given an input field (lexical for text, numerical for numbers).
# The radius is defined by the totaldegree of the node
def skitter(_field):
_maxangle = 2 * Math.PI
_ordering = sortBy(_field)
_increment = _maxangle / len(_ordering)
_curangle = 0
g.nodes[0].outdegree
_maxdeg = outdegree.max + 1.0
for _n in _ordering:
_radius = 1 - Math.log((_n.outdegree + 1.0) / _maxdeg)
_radius = _radius * 500.0
_x = 500.0 + _radius * Math.cos(_curangle)
_y = 500.0 + _radius * Math.sin(_curangle)
_n.setX(_x)
_n.setY(_y)
_curangle += _increment
# colors a given edge the "average" of it's two endpoints
def averageEdgeColor(_edge):
_n1 = _edge.getNode1()
_n2 = _edge.getNode2()
_edge.color = averageColor(_n1.color,_n2.color)
from com.hp.hpl.guess.jfreechart import GChartFrame
from com.hp.hpl.guess.jfreechart import GHistoChartFrame
from com.hp.hpl.guess.jfreechart import GPieChartFrame
# plots the distribution of values for a given field in a chart
def plotDistrib(_field,_chart = None, _sortBy = None, legend = 1, visible = 1):
if _sortBy == None:
_sortBy = _field
_l = sortBy(_sortBy)
_names = []
_values = []
for _z in _l:
_names += [_z]
_values += [_z.__getattr__(_field.getName())]
_xlabel = ""
if (_field.getType() == 1):
_xlabel = "Rank Ordered Nodes"
else:
_xlabel = "Rank Ordered Edges"
if _chart == None:
_chart = GChartFrame(_field.getName(),_names,_values,_xlabel,visible,legend)
else:
_chart.addToChart(_field.getName(),_names,_values,_xlabel)
return _chart
def sizecmpd(_a,_b):
return len(_b) - len(_a)
def sizecmpi(_a,_b):
return len(_b) - len(_a)
def plotSizes(_field,legend=0,visible=1):
_groups = groupBy(_field)
_groups.sort(sizecmpd)
_values = []
_names = []
_colors = []
for _g in _groups:
_values += [len(_g)]
_name = _g[0].__getattr__(_field.getName())
if _g == None:
_name = "X"
_names += [_name]
_colors += [_g[0].color]
_chart = GHistoChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
return _chart
def plotSizesPie(_field,legend=0,visible=1):
_groups = groupBy(_field)
_groups.sort(sizecmpd)
_values = []
_names = []
_colors = []
for _g in _groups:
_values += [len(_g)]
_name = _g[0].__getattr__(_field.getName())
if _g == None:
_name = "X"
_names += [_name]
_colors += [_g[0].color]
_chart = GPieChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
return _chart
def plotHistogram(_field,bins=10,legend=0,visible=1):
_sorted = sortBy(_field)
_min = float(_field.min)
_max = float(_field.max)
_binsize = (_max - _min)/float(bins)
_binend = _min + _binsize
_curgroup = []
_values = []
_names = []
_colors = []
_groups = []
for _e in _sorted:
_val = _e.__getattr__(_field.getName())
if _val > _binend:
_groups += [_curgroup]
_values += [len(_curgroup)]
_names += ["<="+str(_binend)];
_colors += [blue]
_binend = _binend + _binsize
_curgroup = []
_curgroup += [_e]
_groups += [_curgroup]
_values += [len(_curgroup)]
_names += ["<="+str(_max)];
_colors += [blue]
_chart = GHistoChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
return _chart
# calculates the distance between two nodes
def distance(_node1,_node2):
return Math.sqrt(((_node1.x - _node2.x) * (_node1.x - _node2.x)) + ((_node1.y - _node2.y) * (_node1.y - _node2.y)))
def ninverse(_set):
_toret = []
for _t in g.nodes:
if _t not in _set:
_toret += [_t]
return _toret
def einverse(_set):
_toret = []
for _t in g.edges:
if _t not in _set:
_toret += [_t]
return _toret
import math
def floatRange(a, b, inc):
try: x = [float(a)]
except: return False
for i in range(1, int(math.ceil((b - a ) / inc))):
x. append(a + i * inc)
return x