allpy
view blocks3d/Kliki.py @ 303:578bc81d5e62
Added explanation for algorithm to add gapped line to base Alignment
author | Daniil Alexeyevsky <me.dendik@gmail.com> |
---|---|
date | Thu, 16 Dec 2010 19:08:16 +0300 |
parents | 3161cdaf2ff9 |
children |
line source
1 # -*- coding: cp1251 -*-
3 #########################################################################
4 # ???????? ?????-???????: ????? ????????????? ????????/?????????
5 #########################################################################
10 """
11 ?????????? ????? ? ??????? ?????????? ????? ????????? ? ???
13 Usage:
15 from Kliki import Kliki
16 l = Kliki(graf)
17 l.kliki # ??? ????? ?????
18 """
30 """
31 graf[???????1][???????2] = 1 - ???? ?????, 0 - ??? ?????
33 kliki - ?????? ????, ????? - ?????? ??????? ?????????, ???????? ? ?????? ???????
35 compsub - ?????? ??????? ??? ??????? ????
36 """
47 """
48 ??????? ??????? ??????
50 graf - ??????? ????????.
51 ???? graf[1][2] == 1, ?? 1 ???????? ? 2
52 ???? graf[1][2] == 0, ?? 1 ?? ???????? ? 2
54 graf[N][N] = 1 ??? ???? N
56 cost - ??????? ?????????? graf (??????????????)
57 ?????? ???? ?????? ????? ??????????.
58 ??? ?????? ????, ??? ???? ??????? ??? ?????
59 ???????????? ??? fast_algorithm ? ??? ?????????? ????
62 limit_count - ???????????? ????? ????, ??????? ?????
63 ???? ?????? 0, ?? ??????????? ??? ?????
65 min_size - min size of returning klika
67 timeout - time in sec. for BRON-KERBOSH algorithm
69 """
92 # delete atoms which have not enough number of connections
134 # RUN BRON-KERBOSH
147 # ?????????? ?????????? ????? ?? ???????? ????? ????????? ? ???
153 ## max_l=0 # ???????????? ??????
154 ## min_l=len(self.kliki[0]) # ??????????? ??????
163 ## max_l = max(max_l,len(klika))
164 ## min_l = min(min_l,len(klika))
175 #print self.cost
190 ## print l
192 # ??????????? ?? ?? ???????? ????? ???? cost
205 continue
210 break
214 continue
239 ## kliki.reverse()
259 """
260 ???????? ?????-??????? ?????? ????????????? ??????? ????????
261 http://ru.wikipedia.org/wiki/????????_?????_?_???????
263 compsub - ?????? ?????? ????
264 candidates - ?????? ??????????????? ?????????? ? ????
265 used - ?????? ????????????? ?????????? ? ????
266 """
279 # ????...
289 # ???????? candidates ? used ?? ??????
291 #print depth
299 # ???? candidates ?? ?????
305 continue
312 # ? used ?? ???????? ???????, ??????????? ?? ????? ????????? ?? candidates
313 # (??? ?? used ?? ????????? ???? ?? ? 1 ?? candidates)
320 break
329 continue
337 # ???????? ??????? v ?? candidates ? ????????? ?? ? compsub
345 # ????????? new_candidates ? new_used, ?????? ?? candidates ? used ???????, ?? ??????????? ? v
346 # (?? ????, ???????? ?????? ??????????? ? v)
361 # ??????? v ?? candidates ? ???????? ? used
366 # ???? new_candidates ? new_used ?????
368 # compsub ? ?????
372 # ????? ?????????? ???????? bron_kerbosh(new_candidates, new_used)
377 # TIMEOUT check start
383 return
384 # TIMEOUT check end
397 continue
400 # ??????? v ?? compsub
415 """
416 Fast algorithm
417 """
427 # try find new klika
430 # exclude previous klika atoms
447 break
451 # exclude some atoms
467 # all atoms are equal
468 break
503 continue
517 continue
525 # try add other atoms
534 continue
541 break
544 # add atom i
548 break
552 # no new atoms
553 break
557 # keys1 is klika