Beispiel #1
0
 def hops_to_node(self, nodes: Nodes, x: Any) -> Iterable[Hop]:
     return unique_everseen(
         chain.from_iterable(
             edges.hops_to_node(nodes, x) for edges in self.edgess))
Beispiel #2
0
 def make_graph(self):
     lg.info(funcname())
     
     # parse all events and fill base structures
     for _,v in self.raw_events.iteritems():
         tm = TimeNode(v.time)
         if not tm in self.times:
             self.times.add(tm)
             self.time_events[tm] = list()
             pass
         
         th = ThreadNode(v.thread, v.proc)
         if not th in self.threads:
             self.threads.add(th)
             self.thread_events[th] = list()
             pass
         
         ev = EventNode(tm, th, v)
         self.thread_events[th].append(ev)
         self.time_events[tm].append(ev)
         self.events.append(ev)
         
         pass
     
     # build the linked list of event and thread nodes
     for th, elist in self.thread_events.iteritems():
         elist[0].set_parent(th)
         elist[0].first = True
         
         for a,b in pair_iter(elist):
             b.set_parent(a)
             pass
         pass
     
     # build time events list unique by thread
     for tm, elist in self.time_events.iteritems():
         self.time_events_th_uniq[tm] = list(unique_everseen(elist, lambda x: x.thread))
     
     # set invisible nodes to fix time ranking
     for tma, tmb in pair_iter(sorted(self.times)):
         elista = self.time_events_th_uniq[tma]
         elistb = self.time_events_th_uniq[tmb]
         have_threads_a = {e.thread for e in elista}
         have_threads_b = {e.thread for e in elistb}
         lack_threads_b = self.threads - have_threads_b
         
         for th in lack_threads_b:
             if th in have_threads_a:
                 e = (e for e in elista if e.thread == th).next()
                 while e.child and e.child.time == e.time: 
                     e = e.child
                     pass
                 if e.child:
                     ie = InvisibleNode(str(th) + str(tmb) + 'invis')
                     ie.thread = th
                     ie.time = tmb
                     e.set_sec_child(ie)
                     e.child.set_sec_parent(ie)
                     ie.set_parent(e)
                     ie.set_child(e.child)
                     self.time_events_th_uniq[tmb].append(ie)
                     
                     self.invis_nodes.append(ie)
                     pass
                 pass
             pass # for th in lac_th
         pass
     
     self.find_hor_links()
     self.shrink_graph()
     
     pass
Beispiel #3
0
 def predecessors_of(self, x):
     return unique_everseen(
         chain.from_iterable(g.predecessors_of(x) for g in self.graphs))
Beispiel #4
0
def genall(
    xs: List[int],
    ops: List[Callable] = [Add, Sub, Revsub, Mul]
) -> Iterable[str]:
    yield from unique_everseen(genall_(xs, ops))
Beispiel #5
0
 def all_nodes(self):
     return unique_everseen(
         chain.from_iterable(g.all_nodes() for g in self.graphs))