User Tools

Site Tools


chicoutimi_2016:doa_de_van_ham_et_van_wijk

Visual Analytics Course

Instructor: Guy Melançon (email: Guy dot Melancon at labri dot fr)

Chicoutimi Summer 2016 roadmap / May 3, 3pm course

DOA de van Ham et van Wijk

Voir la portion de cours sur l'indice DOA.

Cet algorithme calcule la valeur DOA des sommets en fonction d'un focus. Le graphe doit être accompagné d'un arbre binaire décrivant un clustering hiérarchique, typiquement obtenu par clustering hiérarchique ascendant.

DOA.py
'''
Created on 28 mars 2012
 
@author: melancon
'''
 
from tulip import *
import Queue
 
class DOA(object):
    '''
    implements Furnas' original DOI function
    with accompanying animation function
    most functions require that one node be selected in the tree
    '''
 
    def __init__(self, tree):
        '''
        Constructor
        '''
        super(DOA, self).__init__()
 
        self.tree = tree
        self.root = self.tree.getSource()
        self.API = self.tree.getDoubleProperty('API')
 
        self.cluster_distance_prop = self.tree.getDoubleProperty('cluster_distance')
        self.cluster_barycenters = self.tree.getLayoutProperty('barycenter')
 
        #self.__API__(self.root, 0)
        self.Dist2Focus = self.tree.getIntegerProperty('Dist2Focus')
        self.visible = self.tree.getBooleanProperty('visible')
        self.visible.setAllNodeValue(True)
        self.color = self.tree.getColorProperty('viewColor')
 
    def __getFocusNode__(self):
        viewSelection = self.tree.getBooleanProperty('viewSelection')
        for node in self.tree.getNodes():
            if viewSelection[node]:
                return node
        return None
 
    def performDOA(self, degree_of_abstraction, selectionProperty):
        '''
        grabs all node having DOI less than or equal to layer
        displays them and hides all others
        '''
        updateVis = self.tree.getBooleanProperty('updateVis')
        updateVis.setAllNodeValue(False)
        selectionProperty.setAllNodeValue(False)
        d_root = self.cluster_distance_prop[self.root]
        focus = self.__getFocusNode__()
        print focus, ', ', self.cluster_barycenters[focus]
        queue = Queue.Queue()
        queue.put(self.root)
        while not queue.empty():
            n = queue.get()
            updateVis[n] = True
            #selectionProperty[n] = True
            for child in self.tree.getOutNodes(n):
                selectionProperty[n] = True
                doa_value = degree_of_abstraction(self.cluster_barycenters[focus], self.cluster_barycenters[child])
                if self.cluster_distance_prop[child] > doa_value * d_root:
                    queue.put(child)
 
        for node in self.tree.getNodes():
            if self.visible[node] and (not updateVis[node]):
                self.__fadeOut__(node)
            elif (not self.visible[node]) and updateVis[node]:
                self.__fadeIn__(node)
            elif self.visible[node] and updateVis[node]:
                self.__fadeIn__(node)
            else:
                self.__fadeOut__(node)
            self.visible[node] = updateVis[node]
 
    def __fadeOut__(self, node):
        c = tlp.Color(0, 0, 255, 255)
        self.color[node] = c
        if __name__ == '__main__':
            updateVisualization()
        return True
 
    def __fadeIn__(self, node):
        c = tlp.Color(255, 0, 0, 255)
        self.color[node] = c
        if __name__ == '__main__':
            updateVisualization()
        return True
 
 
def doa_const(p1, p2):
    return 0.9
 
def doa_linear(p1, p2):
    print 'dao for pts ', p1, ', ', p2
    doa_bound = 0.2
    dist = p1.dist(p2)
    if dist <  100.0:
        print doa_bound * dist / 100.0
        print '*****************'
        return doa_bound * dist / 100.0
    else:
        print doa_bound
        print '*****************'
        return doa_bound
 
def main(graph):
    doa = DOA(graph)
    tree_sel = doa.tree.getLocalBooleanProperty('DOA_selection')
    doa.performDOA(doa_const, tree_sel)
/net/html/perso/melancon/Visual_Analytics_Course/data/pages/chicoutimi_2016/doa_de_van_ham_et_van_wijk.txt · Last modified: 2016/05/26 21:51 by melancon