~gnome-zeitgeist/gnome-zeitgeist/Dashboard2

« back to all changes in this revision

Viewing changes to src/graph.py

  • Committer: Seif Lotfy
  • Date: 2009-08-28 19:35:28 UTC
  • Revision ID: seif@lotfy.com-20090828193528-31ft7ho6v8mns2no
corrected the graphs

Show diffs side-by-side

added added

removed removed

Lines of Context:
44
44
            
45
45
        self.events.append(event)
46
46
        
47
 
    def get_neighbourhood(self, node, depth, check_list ):
 
47
    def get_neighbourhood(self, node, depth, check_list, travers = ["+","-"], node_list=[]  ):
48
48
        #print "---> ", node
49
 
        if not node.id in check_list:
50
 
            check_list.append(node.id)
51
 
            root = Node(node.id)
52
 
            root.item = copy.copy(node.item)
53
 
            if depth > 0:
54
 
                
 
49
        node_list.append(node)
 
50
        root = Node(node.id)
 
51
        root.item = copy.copy(node.item)
 
52
        if depth > 0:
 
53
            
 
54
            if "+" in travers:
55
55
                for out in node.outgoing.values():
56
56
                    root_out = copy.copy(out)
57
57
                    root_out.first_node = root
58
 
                    next = self.get_neighbourhood(root_out.last_node, depth - 1, check_list)
 
58
                    next = self.get_neighbourhood(root_out.last_node, depth - 1, check_list, ["+"], node_list)
59
59
                    if next:
60
 
                        root_out.last_node = next
61
 
                        root.outgoing[out.last_node.id] =  root_out
62
 
                        
 
60
                        arrow = root.id+"->"+next.id
 
61
                        if not arrow in check_list:
 
62
                            check_list.append(arrow)
 
63
                            root_out.last_node = next
 
64
                            root.outgoing[out.last_node.id] =  root_out
 
65
                            
 
66
            if "-" in travers:
63
67
                for ins in node.incoming.values(): 
64
68
                    root_in = copy.copy(ins)
65
69
                    root_in.last_node = root
66
 
                    prev = self.get_neighbourhood(root_in.first_node, depth - 1, check_list)
 
70
                    prev = self.get_neighbourhood(root_in.first_node, depth - 1, check_list, ["-"], node_list)
67
71
                    if prev:
68
 
                        root_in.first_node = prev
69
 
                        root.incoming[ins.first_node.id] =  root_in
70
 
                
71
 
            return root
72
 
        return None
 
72
                        arrow = prev.id+"->"+root.id
 
73
                        if not arrow in check_list:
 
74
                            check_list.append(arrow)
 
75
                            root_in.first_node = prev
 
76
                            root.incoming[ins.first_node.id] =  root_in
 
77
            
 
78
        return root
73
79
        
74
80
class Node():
75
81
    def __init__(self, id):