Документ взят из кэша поисковой машины. Адрес оригинального документа : http://kodomo.fbb.msu.ru/hg/allpy/file/e83572fff43f/allpy/graph.py
Дата изменения: Unknown
Дата индексирования: Mon Feb 4 01:04:16 2013
Кодировка:
allpy: e83572fff43f allpy/graph.py

allpy

view allpy/graph.py @ 746:e83572fff43f

Roll-back a bug introduces by dirty hand-merge in [723]. (closes #74) (see #76) Boris! Please do not do dirty hand merges! If you did hg fetch here, this bug would not appear! Please, be extremely careful when you do hand merges and double-check your changes. Do a diff with each parent and see what you remove related to the parent! If someone else's code is involved in the merge (which is almost always the case), do that diff twice just to make sure you have not missed anything!
author Daniil Alexeyevsky <dendik@kodomo.fbb.msu.ru>
date Mon, 11 Jul 2011 14:29:54 +0400
parents f9feb1d40968
children 3cc7ef543da5
line source
1 from datetime import datetime, timedelta
2 from copy import copy
4 class TimeoutError(Exception):
5 pass
7 class Graph(dict):
8 """ Undirected weighted graph
10 graph[vertex1][vertex2] = weight
11 * vertex1 != vertex2 (no such edges)
12 * weight is float in (0, 1] or 1 (if all edges are equal)
13 * symmetrical
15 Features:
16 * this graph cannot contain vertices without any edges
18 >>> g = Graph()
19 >>> g.set_edge(1, 2)
20 >>> g.fast_cliques()
21 Fast algorithm started
22 [frozenset([1, 2])]
23 >>> g.set_edge(2, 3)
24 >>> g.set_edge(1, 3)
25 >>> g.fast_cliques()
26 Fast algorithm started
27 [frozenset([1, 2, 3])]
28 >>> g.bron_kerbosh()
29 Bron and Kerbosh algorithm started
30 [frozenset([1, 2, 3])]
31 >>> g.cliques()
32 Bron and Kerbosh algorithm started
33 [frozenset([1, 2, 3])]
35 """