I hope I understood correctly what is this: it's automatically changed by the build...
[guess.git] / scripts / Main-applet.py
blobe8d317b3692e65d3a50b32fe3c7887dcf7726457
2 # AUTOMATICALLY GENERATED
3 # Defines wrapper methods that can be used as shortcuts in the interpreter
5 def execfile(s):
6 interp.execfile(s)
8 def makeFromGDF(filename):
9 g.makeFromGDF(filename)
11 def centerAfterLayout(state):
12 g.centerAfterLayout(state)
14 def removeNodeComplete(n):
15 g.removeNodeComplete(n)
17 def initConnection(*d):
18 if len(d) == 1:
19 r.initConnection(d[0])
20 elif len(d) == 0:
21 r.initConnection()
22 else:
23 raise ValueError("Incorrect number of arguments")
26 def showTitle(title,time):
27 vf.showTitle(title,time)
29 def sugiyamaLayout(*d):
30 if len(d) == 0:
31 g.sugiyamaLayout()
32 elif len(d) == 1:
33 g.sugiyamaLayout(d[0])
34 else:
35 raise ValueError("Incorrect number of arguments")
38 def getAppletContext():
39 return Guess.getAppletContext()
41 def generateColors(*d):
42 if len(d) == 3:
43 return Colors.generateColors(d[0],d[1],d[2])
44 elif len(d) == 4:
45 return Colors.generateColors(d[0],d[1],d[2],d[3])
46 else:
47 raise ValueError("Incorrect number of arguments")
50 def makeFromGML(filename):
51 g.makeFromGML(filename)
53 def searchOverlap(range):
54 return DefaultRangeManager.searchOverlap(range)
56 def exportPS(filename):
57 v.exportPS(filename)
59 def compressOverlapping():
60 g.compressOverlapping()
62 def exportSWF(filename):
63 v.exportSWF(filename)
65 def exportPDF(filename):
66 v.exportPDF(filename)
68 def groupBy(*d):
69 if len(d) == 2:
70 return g.groupBy(d[0],d[1])
71 elif len(d) == 1:
72 return g.groupBy(d[0])
73 else:
74 raise ValueError("Incorrect number of arguments")
77 def jSpringLayout(*d):
78 if len(d) == 0:
79 g.jSpringLayout()
80 elif len(d) == 1:
81 g.jSpringLayout(d[0])
82 else:
83 raise ValueError("Incorrect number of arguments")
86 def setDisplayBackground(c):
87 v.setDisplayBackground(c)
89 def setNodeDisappearBy(nodeDisBy):
90 Morpher.setNodeDisappearBy(nodeDisBy)
92 def gemLayout(*d):
93 if len(d) == 0:
94 g.gemLayout()
95 elif len(d) == 1:
96 g.gemLayout(d[0])
97 else:
98 raise ValueError("Incorrect number of arguments")
101 def setTitleColor(aColor):
102 vf.setTitleColor(aColor)
104 def averageColor(c1,c2):
105 return Colors.averageColor(c1,c2)
107 def makeErdosRenyiRandom(nodes,p):
108 g.makeErdosRenyiRandom(nodes,p)
110 def ls(*d):
111 if len(d) == 2:
112 db.loadState(d[0],d[1])
113 elif len(d) == 1:
114 db.loadState(d[0])
115 else:
116 raise ValueError("Incorrect number of arguments")
119 def exportGDF(filename):
120 g.exportGDF(filename)
122 def getNodeAppearAfter():
123 return Morpher.getNodeAppearAfter()
125 def weightedKKLayout(*d):
126 if len(d) == 0:
127 g.weightedKKLayout()
128 elif len(d) == 1:
129 g.weightedKKLayout(d[0])
130 else:
131 raise ValueError("Incorrect number of arguments")
134 def removeEdgeComplete(e):
135 g.removeEdgeComplete(e)
137 def kkLayout(*d):
138 if len(d) == 0:
139 g.kkLayout()
140 elif len(d) == 1:
141 g.kkLayout(d[0])
142 elif len(d) == 2:
143 g.kkLayout(d[0],d[1])
144 elif len(d) == 3:
145 g.kkLayout(d[0],d[1],d[2])
146 else:
147 raise ValueError("Incorrect number of arguments")
150 def addNodeField(fieldName,sqlType,defaultValue):
151 return g.addNodeField(fieldName,sqlType,defaultValue)
153 def exportCGM(filename):
154 v.exportCGM(filename)
156 def createConvexHull(seq,c):
157 return vf.createConvexHull(seq,c)
159 def isRConnected():
160 return r.isConnected()
162 def mdsLayout():
163 g.mdsLayout()
165 def makeLattice1DRandom(nodes,tor):
166 g.makeLattice1DRandom(nodes,tor)
168 def removeComplete(seq):
169 g.removeComplete(seq)
171 def setEdgeAppearAfter(edgeAppearAfter):
172 Morpher.setEdgeAppearAfter(edgeAppearAfter)
174 def makeFromDL(filename):
175 g.makeFromDL(filename)
177 def remove(seq):
178 return g.remove(seq)
180 def removeEdge(e):
181 return g.removeEdge(e)
183 def getNodeSchema():
184 return g.getNodeSchema()
186 def getEdgeDisappearBy():
187 return Morpher.getEdgeDisappearBy()
189 def addRange(o,range):
190 DefaultRangeManager.addRange(o,range)
192 def stopMovie():
193 v.stopMovie()
195 def addEdge(node1,node2):
196 return g.addEdge(node1,node2)
198 def getMTF():
199 return Guess.getMTF()
201 def getSynchronous():
202 return Guess.getSynchronous()
204 def setBackgroundImage(*d):
205 if len(d) == 1:
206 v.setBackgroundImage(d[0])
207 elif len(d) == 3:
208 v.setBackgroundImage(d[0],d[1],d[2])
209 else:
210 raise ValueError("Incorrect number of arguments")
213 def jkkLayout1(*d):
214 if len(d) == 0:
215 g.jkkLayout1()
216 elif len(d) == 1:
217 g.jkkLayout1(d[0])
218 else:
219 raise ValueError("Incorrect number of arguments")
222 def setNodeAppearAfter(nodeAppearAfter):
223 Morpher.setNodeAppearAfter(nodeAppearAfter)
225 def removeDisconnected():
226 return g.removeDisconnected()
228 def dagLayout():
229 g.dagLayout()
231 def expandOverlapping():
232 g.expandOverlapping()
234 def dragwindow():
235 DragWindow.create()
237 def getEdgeAppearAfter():
238 return Morpher.getEdgeAppearAfter()
240 def stoplog():
241 interp.stoplog()
243 def setMTF(state):
244 Guess.setMTF(state)
246 def add(seq):
247 g.add(seq)
249 def drawwindow():
250 DrawWindow.create()
252 def removeNode(n):
253 return g.removeNode(n)
255 def hideDisconnected():
256 g.hideDisconnected()
258 def getDirected():
259 return vf.getDirected()
261 def springLayout(*d):
262 if len(d) == 0:
263 g.springLayout()
264 elif len(d) == 1:
265 g.springLayout(d[0])
266 else:
267 raise ValueError("Incorrect number of arguments")
270 def setDirected(dir):
271 vf.setDirected(dir)
273 def jfrLayout():
274 g.jfrLayout()
276 def setPageRankBias(bias):
277 g.setPageRankBias(bias)
279 def setFrozen(state):
280 v.setFrozen(state)
282 def makeEppsteinRandom(nodes,edges,r):
283 g.makeEppsteinRandom(nodes,edges,r)
285 def circleLayout(*d):
286 if len(d) == 0:
287 g.circleLayout()
288 elif len(d) == 2:
289 g.circleLayout(d[0],d[1])
290 elif len(d) == 4:
291 g.circleLayout(d[0],d[1],d[2],d[3])
292 else:
293 raise ValueError("Incorrect number of arguments")
296 def weakComponentClusters():
297 return g.weakComponentClusters()
299 def rshutdown():
300 r.shutdown()
302 def translateLayout(newX,newY):
303 g.translateLayout(newX,newY)
305 def removeBackgroundImage():
306 v.removeBackgroundImage()
308 def getSubgraph(name):
309 return Subgraph.getRootSubgraph(name)
311 def groupAndSortBy(*d):
312 if len(d) == 1:
313 return g.groupAndSortBy(d[0])
314 elif len(d) == 2:
315 return g.groupAndSortBy(d[0],d[1])
316 else:
317 raise ValueError("Incorrect number of arguments")
320 def searchContained(range):
321 return DefaultRangeManager.searchContained(range)
323 def physicsLayout(*d):
324 if len(d) == 0:
325 g.physicsLayout()
326 elif len(d) == 1:
327 g.physicsLayout(d[0])
328 else:
329 raise ValueError("Incorrect number of arguments")
332 def getGraphMap():
333 return r.getGraphMap()
335 def sortBy(*d):
336 if len(d) == 2:
337 return g.sortBy(d[0],d[1])
338 elif len(d) == 1:
339 return g.sortBy(d[0])
340 else:
341 raise ValueError("Incorrect number of arguments")
344 def reval(s):
345 return r.evalString(s)
347 def removeConvexHulls(seq):
348 vf.removeConvexHulls(seq)
350 def randomLayout(*d):
351 if len(d) == 0:
352 g.randomLayout()
353 elif len(d) == 2:
354 g.randomLayout(d[0],d[1])
355 else:
356 raise ValueError("Incorrect number of arguments")
359 def randomColor(*d):
360 if len(d) == 0:
361 return Colors.randomColor()
362 elif len(d) == 1:
363 return Colors.randomColor(d[0])
364 else:
365 raise ValueError("Incorrect number of arguments")
368 def moveLayout(newX,newY):
369 g.moveLayout(newX,newY)
371 def sql(expression):
372 db.q(expression)
374 def morph(state,duration):
375 g.morph(state,duration)
377 def makeSimpleDirectedRandom(nodes,edges):
378 g.makeSimpleDirectedRandom(nodes,edges)
380 def exportJPG(filename):
381 v.exportJPG(filename)
383 def radialLayout(center):
384 g.radialLayout(center)
386 def density():
387 return g.density()
389 def overrideArrowLength(length):
390 Arrow.overrideArrowLength(length)
392 def rescaleLayout(*d):
393 if len(d) == 2:
394 g.rescaleLayout(d[0],d[1])
395 elif len(d) == 1:
396 g.rescaleLayout(d[0])
397 else:
398 raise ValueError("Incorrect number of arguments")
401 def setSynchronous(state):
402 Guess.setSynchronous(state)
404 def weightedSpringLayout(*d):
405 if len(d) == 2:
406 g.weightedSpringLayout(d[0],d[1])
407 elif len(d) == 3:
408 g.weightedSpringLayout(d[0],d[1],d[2])
409 else:
410 raise ValueError("Incorrect number of arguments")
413 def resizeLinear(f,start,end):
414 g.resizeLinear(f,start,end)
416 def exportGIF(filename):
417 v.exportGIF(filename)
419 def binPackLayout(*d):
420 if len(d) == 0:
421 g.binPackLayout()
422 elif len(d) == 1:
423 g.binPackLayout(d[0])
424 else:
425 raise ValueError("Incorrect number of arguments")
428 def getJythonConsole():
429 return Guess.getJythonConsole()
431 def colorize(*d):
432 if len(d) == 1:
433 g.colorize(d[0])
434 elif len(d) == 3:
435 g.colorize(d[0],d[1],d[2])
436 elif len(d) == 4:
437 g.colorize(d[0],d[1],d[2],d[3])
438 else:
439 raise ValueError("Incorrect number of arguments")
442 def frLayout(*d):
443 if len(d) == 0:
444 g.frLayout()
445 elif len(d) == 2:
446 g.frLayout(d[0],d[1])
447 else:
448 raise ValueError("Incorrect number of arguments")
451 def setEdgeDisappearBy(edgeDisBy):
452 Morpher.setEdgeDisappearBy(edgeDisBy)
454 def infowindow(*d):
455 if len(d) == 0:
456 InfoWindow.create()
457 elif len(d) == 0:
458 SpreadSheet.create()
459 else:
460 raise ValueError("Incorrect number of arguments")
463 def getDisplayBackground():
464 return v.getDisplayBackground()
466 def edgeBetweennessClusters(numEdgesToRemove):
467 return g.edgeBetweennessClusters(numEdgesToRemove)
469 def exportPNG(filename):
470 v.exportPNG(filename)
472 def exportSVG(filename):
473 v.exportSVG(filename)
475 def ss(state):
476 db.saveState(state)
478 def overrideArrowWidth(width):
479 Arrow.overrideArrowWidth(width)
481 def addEdgeField(fieldName,sqlType,defaultValue):
482 return g.addEdgeField(fieldName,sqlType,defaultValue)
484 def getPageRankBias():
485 return g.getPageRankBias()
487 def resizeRandom(f,start,end):
488 g.resizeRandom(f,start,end)
490 def sugiyamaLayout2():
491 g.sugiyamaLayout2()
493 def setQuality(requestedQuality):
494 v.setQuality(requestedQuality)
496 def removeConvexHull(c):
497 vf.removeConvexHull(c)
499 def exportJAVA(filename):
500 v.exportJAVA(filename)
502 def getConvexHulls():
503 return vf.getConvexHulls()
505 def getEdgeSchema():
506 return g.getEdgeSchema()
508 def startMovie(*d):
509 if len(d) == 2:
510 v.startMovie(d[0],d[1])
511 elif len(d) == 3:
512 v.startMovie(d[0],d[1],d[2])
513 else:
514 raise ValueError("Incorrect number of arguments")
517 def exportEPS(filename):
518 v.exportEPS(filename)
520 def makeKleinbergRandom(nodes,clust):
521 g.makeKleinbergRandom(nodes,clust)
523 def makeBarabasiAlbertRandom(vert,edges,evolve):
524 g.makeBarabasiAlbertRandom(vert,edges,evolve)
526 def isomLayout(*d):
527 if len(d) == 0:
528 g.isomLayout()
529 elif len(d) == 1:
530 g.isomLayout(d[0])
531 else:
532 raise ValueError("Incorrect number of arguments")
535 def exportEMF(filename):
536 v.exportEMF(filename)
538 def makeFromPajek(filename):
539 g.makeFromPajek(filename)
541 def center(*d):
542 if len(d) == 0:
543 v.center()
544 elif len(d) == 1:
545 v.center(d[0])
546 else:
547 raise ValueError("Incorrect number of arguments")
550 def setRankerWeightField(f):
551 g.setRankerWeightField(f)
553 def help(tohelp):
554 Guess.help(tohelp)
556 def log(filename):
557 interp.log(filename)
559 def searchContains(range):
560 return DefaultRangeManager.searchContains(range)
562 def makeLattice2DRandom(nodes,tor):
563 g.makeLattice2DRandom(nodes,tor)
565 def readjustEdges():
566 g.readjustEdges()
568 def jkkLayout2(*d):
569 if len(d) == 0:
570 g.jkkLayout2()
571 elif len(d) == 1:
572 g.jkkLayout2(d[0])
573 else:
574 raise ValueError("Incorrect number of arguments")
577 def complement(seq):
578 return g.complement(seq)
580 def removeSelfLoops():
581 return g.removeSelfLoops()
583 def biComponentClusters():
584 return g.biComponentClusters()
586 def getNodeDisappearBy():
587 return Morpher.getNodeDisappearBy()
589 def searchExact(range):
590 return DefaultRangeManager.searchExact(range)
592 def makeSimpleRandom(nodes,edges):
593 g.makeSimpleRandom(nodes,edges)
595 def getStates():
596 return db.getStates()
600 __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"}
602 def addNode(_name,**_extra):
603 _temp = g.addNode(_name)
604 if not isinstance(_name,Class.forName("com.hp.hpl.guess.Node")):
605 _temp.label = _name
606 for _toset in _extra.keys():
607 _temp.__setattr__(_toset,_extra[_toset])
608 return _temp
610 def copyNode(_template,_name,**_extra):
611 if not isinstance(_template,Class.forName("com.hp.hpl.guess.Node")):
612 raise TypeError,'First argument nust be a template Node'
613 if not isinstance(_name,Class.forName("org.python.core.PyString")):
614 raise TypeError,'Second argument must be a name'
615 _temp = g.addNode(_name)
616 for _field in Node.fieldNames():
617 if (_field != "name"):
618 _temp.__setattr__(_field,_template.__getattr__(_field))
619 for _toset in _extra.keys():
620 _temp.__setattr__(_toset,_extra[_toset])
621 return(_temp)
623 def addEdge(*d,**_extra):
624 return addUndirectedEdge(*d,**_extra)
626 def addDirectedEdge(*d,**_extra):
627 _temp = None
628 if d.__len__() == 1:
629 _temp = g.addEdge(d[0])
630 elif d.__len__() == 2:
631 return g.addDirectedEdge(d[0],d[1])
632 for _toset in _extra.keys():
633 _temp.__setattr__(_toset,_extra[_toset])
634 if not _extra.has_key("label"):
635 _temp.label = str(_temp.weight)
636 return(_temp)
638 def addUndirectedEdge(*d,**_extra):
639 _temp = None
640 if d.__len__() == 1:
641 _temp = g.addEdge(d[0])
642 elif d.__len__() == 2:
643 return g.addUndirectedEdge(d[0],d[1])
644 for _toset in _extra.keys():
645 _temp.__setattr__(_toset,_extra[_toset])
646 if not _extra.has_key("label"):
647 _temp.label = str(_temp.weight)
648 return(_temp)
650 # Some demo functions that manipulate the graph in various ways
652 from java.lang import Math
654 # iteratively removes all nodes that have
655 # a total degree of 1
656 # assumes self loops have been removed
657 def removeLeaves():
658 g.nodes[0].totaldegree
659 _m = (totaldegree <= 1)
660 _toRet = []
661 while _m.__len__() > 0:
662 _toRet += remove(_m)
663 _m = (totaldegree <= 1)
664 return _toRet
668 # iteratively removes nodes that have an outdegree
669 # of introduces a new edge
670 # assumes self loops have been removed
671 def shortcutNodes():
672 g.nodes[0].totaldegree
673 _m = (totaldegree == 2)
674 _toRet = []
675 _added = []
676 while len(_m) > 0:
677 for _z in _m:
678 _pot = _z.getNeighbors()
679 if len(_pot) == 2:
680 if len(_pot[0]-_pot[1]) == 0:
681 _added += [addEdge(_pot[0],_pot[1])]
682 _toRet += removeNode(_z)
683 _m = (totaldegree == 2)
684 _temp = intersectionHelper(_toRet,_added)
685 return [_temp[0],_temp[1]]
687 # iteratively call removeLeaves and shortcutNodes to
688 # condense the graph
689 def condenseGraph():
690 _toRet = []
691 _added = []
692 _toRet += removeDisconnected()
693 _toRet += removeSelfLoops()
694 g.nodes[0].totaldegree
695 _t1 = (totaldegree <= 1)
696 _t2 = (totaldegree == 2)
697 while (_t1.__len__() > 0) | (_t2.__len__() > 0):
698 _toRet += removeLeaves()
699 _scr = shortcutNodes()
700 _toRet += _scr[0]
701 _added += _scr[1]
702 _t1 = (totaldegree <= 1)
703 _t2 = (totaldegree == 2)
704 _temp = intersectionHelper(_toRet,_added)
705 return [_temp[0],_temp[1]]
707 def intersectionHelper(_l1,_l2):
708 _templist = _l1 & _l2
709 _ln1 = []
710 _ln2 = []
711 for _elem in _l1:
712 if _elem not in _templist:
713 _ln1 += [_elem]
714 for _elem in _l2:
715 if _elem not in _templist:
716 _ln2 += [_elem]
717 return [_ln1,_ln2]
719 # does a "skitter" plot which lays out nodes around a circle based on the
720 # ordering given an input field (lexical for text, numerical for numbers).
721 # The radius is defined by the totaldegree of the node
722 def skitter(_field):
723 _maxangle = 2 * Math.PI
724 _ordering = sortBy(_field)
725 _increment = _maxangle / len(_ordering)
726 _curangle = 0
727 g.nodes[0].outdegree
728 _maxdeg = outdegree.max + 1.0
729 for _n in _ordering:
730 _radius = 1 - Math.log((_n.outdegree + 1.0) / _maxdeg)
731 _radius = _radius * 500.0
732 _x = 500.0 + _radius * Math.cos(_curangle)
733 _y = 500.0 + _radius * Math.sin(_curangle)
734 _n.setX(_x)
735 _n.setY(_y)
736 _curangle += _increment
738 # colors a given edge the "average" of it's two endpoints
739 def averageEdgeColor(_edge):
740 _n1 = _edge.getNode1()
741 _n2 = _edge.getNode2()
742 _edge.color = averageColor(_n1.color,_n2.color)
744 from com.hp.hpl.guess.jfreechart import GChartFrame
745 from com.hp.hpl.guess.jfreechart import GHistoChartFrame
746 from com.hp.hpl.guess.jfreechart import GPieChartFrame
748 # plots the distribution of values for a given field in a chart
749 def plotDistrib(_field,_chart = None, _sortBy = None, legend = 1, visible = 1):
750 if _sortBy == None:
751 _sortBy = _field
752 _l = sortBy(_sortBy)
753 _names = []
754 _values = []
755 for _z in _l:
756 _names += [_z]
757 _values += [_z.__getattr__(_field.getName())]
758 _xlabel = ""
759 if (_field.getType() == 1):
760 _xlabel = "Rank Ordered Nodes"
761 else:
762 _xlabel = "Rank Ordered Edges"
763 if _chart == None:
764 _chart = GChartFrame(_field.getName(),_names,_values,_xlabel,visible,legend)
765 else:
766 _chart.addToChart(_field.getName(),_names,_values,_xlabel)
767 return _chart
769 def sizecmpd(_a,_b):
770 return len(_b) - len(_a)
772 def sizecmpi(_a,_b):
773 return len(_b) - len(_a)
775 def plotSizes(_field,legend=0,visible=1):
776 _groups = groupBy(_field)
777 _groups.sort(sizecmpd)
778 _values = []
779 _names = []
780 _colors = []
781 for _g in _groups:
782 _values += [len(_g)]
783 _name = _g[0].__getattr__(_field.getName())
784 if _g == None:
785 _name = "X"
786 _names += [_name]
787 _colors += [_g[0].color]
788 _chart = GHistoChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
789 return _chart
791 def plotSizesPie(_field,legend=0,visible=1):
792 _groups = groupBy(_field)
793 _groups.sort(sizecmpd)
794 _values = []
795 _names = []
796 _colors = []
797 for _g in _groups:
798 _values += [len(_g)]
799 _name = _g[0].__getattr__(_field.getName())
800 if _g == None:
801 _name = "X"
802 _names += [_name]
803 _colors += [_g[0].color]
804 _chart = GPieChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
805 return _chart
807 def plotHistogram(_field,bins=10,legend=0,visible=1):
808 _sorted = sortBy(_field)
809 _min = float(_field.min)
810 _max = float(_field.max)
811 _binsize = (_max - _min)/float(bins)
812 _binend = _min + _binsize
813 _curgroup = []
814 _values = []
815 _names = []
816 _colors = []
817 _groups = []
818 for _e in _sorted:
819 _val = _e.__getattr__(_field.getName())
820 if _val > _binend:
821 _groups += [_curgroup]
822 _values += [len(_curgroup)]
823 _names += ["<="+str(_binend)];
824 _colors += [blue]
825 _binend = _binend + _binsize
826 _curgroup = []
827 _curgroup += [_e]
828 _groups += [_curgroup]
829 _values += [len(_curgroup)]
830 _names += ["<="+str(_max)];
831 _colors += [blue]
832 _chart = GHistoChartFrame(_field.getName(),_groups,_values,_names,_colors,visible,legend)
833 return _chart
836 # calculates the distance between two nodes
837 def distance(_node1,_node2):
838 return Math.sqrt(((_node1.x - _node2.x) * (_node1.x - _node2.x)) + ((_node1.y - _node2.y) * (_node1.y - _node2.y)))
840 def ninverse(_set):
841 _toret = []
842 for _t in g.nodes:
843 if _t not in _set:
844 _toret += [_t]
845 return _toret
847 def einverse(_set):
848 _toret = []
849 for _t in g.edges:
850 if _t not in _set:
851 _toret += [_t]
852 return _toret
854 import math
856 def floatRange(a, b, inc):
857 try: x = [float(a)]
858 except: return False
859 for i in range(1, int(math.ceil((b - a ) / inc))):
860 x. append(a + i * inc)
861 return x