8.1 Clustering
Because we are making use of the JUNG system in GUESS we can take advantage 3of the many clustering algorithms already implemented there. These commands will generally generate a set of sets that can then be used in any way you want. Current commands include:
-
biComponentCluster(): BiComponent Clustering
-
edgeBetweennessClusters(): Edge Betweenness Clustering (Newman)
-
weakComponentClusters(): Graph Components
A simple use of these commands is to color each cluster differently. For example:
clusts = weakComponentClusters()
for z in clusts:
z.color = randomColor()
GUESS will also generate groupings (and sorts based on any field). This is done by the groupBy(field) and groupAndSortBy(field) methods. Using these we could color each edge in the sample database by frequency.
clusts = groupAndSortBy(freq)
clustcol = generateColors(blue,red,len(clusts))
for z in range(0,len(clusts)):
clusts[z].color = clustcol[z]
Because resizing and coloring nodes and edges is a fairly straightforward operation we have created a number of shortcuts described below.
You may also make use of the groupBy/sortBy/groupAndSortBy methods when dealing with sets. For example, say we pull out only a subset of nodes (e.g. all those in department 1) and would like to see them ordered by salary (note that we don’t actually have a salary field defined in the sample data set):
dept1 = (dept == ‘dept1’) dept1.sortBy(salary)
or if we wanted to group them by job function we could do:
dept1.groupBy(jobfunc)


