allpy
view allpy/graph.py @ 1106:2b3cad50c2b1
Partially reversed [afed1f] (see #49)
As explained in the ticket, in real life usecases having a monomer belong to
several sequences is sometimes extremely useful. ANY approach to attribution of
monomer to only one sequence will be either confusing or hindering.
* Removed `monomer.sequence` attribute
* Removed unncecessary specialcasing in pickle
* Removed unused tests
* Restored APIs to backward-compatible
* Added deprecated messages to the restored APIs
author | Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru> |
---|---|
date | Sun, 10 Jun 2012 16:08:47 +0400 |
parents | 53690e470eff |
children |
line source
7 pass
10 """ Undirected weighted graph
12 graph[vertex1][vertex2] = weight
13 * vertex1 != vertex2 (no such edges)
14 * weight is float in (0, 1] or 1 (if all edges are equal)
15 * symmetrical
17 Features:
18 * this graph cannot contain vertices without any edges
20 >>> config.debug = True
21 >>> g = Graph()
22 >>> g.set_edge(1, 2)
23 >>> g.fast_cliques()
24 Fast algorithm started
25 [frozenset([1, 2])]
26 >>> g.set_edge(2, 3)
27 >>> g.set_edge(1, 3)
28 >>> g.fast_cliques()
29 Fast algorithm started
30 [frozenset([1, 2, 3])]
31 >>> g.bron_kerbosch()
32 Bron and Kerbosch algorithm started
33 [frozenset([1, 2, 3])]
34 >>> g.cliques()
35 Bron and Kerbosch algorithm started
36 [frozenset([1, 2, 3])]
38 """
56 """ Remove vertex and all involved edges """
64 """ Returns sum of weights of all connections of this vertex """
71 """ Add vertex and corresponding edges from parent_graph
73 Added edges should be contained in self graph
74 (takes care of hanging edges)
75 """
81 """ Deprecated. Use bron_kerbosch() instead """
85 """ Bron and Kerbosch algorithm implementation
87 returns list of cliques
88 clique is frozenset
89 if timeout=-1, it means infinity
90 if timeout has happened, raises TimeoutError
91 """
105 """ return some v from candidates """
109 """ if v from used connected with all from candidates """
113 break
119 """ process call and return list of recursive calls """
151 """ drop vertices untill self becomes a clique """
165 """ add vertices untill self becomes a nonextendible clique """
177 break
187 """ returns list of cliques
189 clique is frozenset
190 """
201 break
208 break
212 """ return list of connected components, remove single vertices """
232 """ returns length-sorted list of cliques
234 clique is frozenset
236 try to execute bron_kerbosch
237 if it raises TimeoutError, executes fast_cliques
238 """