diff options
| author | aozima <[email protected]> | 2013-02-22 13:54:15 +0800 |
|---|---|---|
| committer | aozima <[email protected]> | 2013-02-22 13:54:15 +0800 |
| commit | 8a8f904e1b6239b895fe97a63eaad62cdef67f61 (patch) | |
| tree | 893d8026dedf827fbb060da91dff504b7cb6d300 /components/rtgui/utils/perfect_hash/example-Python/Graph.py | |
| parent | 8421ecfa277eeb813e7c217955328c6329208f38 (diff) | |
| parent | 4e7247e072e9b298a8811e5db9041558fb5e7c68 (diff) | |
Merge branch 'master' into aozima
Conflicts:
bsp/stm32f107/project.uvproj
Diffstat (limited to 'components/rtgui/utils/perfect_hash/example-Python/Graph.py')
| -rw-r--r-- | components/rtgui/utils/perfect_hash/example-Python/Graph.py | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/components/rtgui/utils/perfect_hash/example-Python/Graph.py b/components/rtgui/utils/perfect_hash/example-Python/Graph.py deleted file mode 100644 index f2927719b4..0000000000 --- a/components/rtgui/utils/perfect_hash/example-Python/Graph.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -""" -This example shows how to use the class Graph. - -The class implements a graph with 'N' vertices. First, you connect the -graph with edges, which have a desired value associated. Then the vertex -values are assigned, which will fail if the graph is cyclic. The vertex -values are assigned such that the two values corresponding to an edge add -up to the desired edge value (mod N). -""" -import sys - -sys.path.append('..') -from perfect_hash import Graph - -G = Graph(3) -assert G.assign_vertex_values() == True - -# Now we make an edge between vertex 0 and 1 with desired edge value 2: -G.connect(0, 1, 2) - -# Make another edge 1:2 with desired edge value 1: -G.connect(1, 2, 1) - -# The graph is still acyclic, and assigning values works: -assert G.assign_vertex_values() == True -assert G.vertex_values == [0, 2, 2] - -# What do these values mean? -# When you add the values for edge 0:1 you get 0 + 2 = 2, as desired. -# For edge 1:2 you add 2 + 2 = 4 = 1 (mod 3), as desired. - -# Adding edge 0:2 produces a loop, so the graph is no longer acyclic. -# Assigning values fails. -G.connect(0, 2, 0) - -assert G.assign_vertex_values() == False - - -print 'OK' |
