fenfire-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ff-cvs] libvob/vob/demo/multifil randgraph.py


From: Janne V. Kujala
Subject: [ff-cvs] libvob/vob/demo/multifil randgraph.py
Date: Tue, 19 Aug 2003 06:20:51 -0400

CVSROOT:        /cvsroot/libvob
Module name:    libvob
Branch:         
Changes by:     Janne V. Kujala <address@hidden>        03/08/19 06:20:51

Modified files:
        vob/demo/multifil: randgraph.py 

Log message:
        add an option for choosing either path-2-connected or path-3+-connected 
nodes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/vob/demo/multifil/randgraph.py.diff?tr1=1.27&tr2=1.28&r1=text&r2=text

Patches:
Index: libvob/vob/demo/multifil/randgraph.py
diff -u libvob/vob/demo/multifil/randgraph.py:1.27 
libvob/vob/demo/multifil/randgraph.py:1.28
--- libvob/vob/demo/multifil/randgraph.py:1.27  Fri Aug 15 05:52:10 2003
+++ libvob/vob/demo/multifil/randgraph.py       Tue Aug 19 06:20:50 2003
@@ -61,6 +61,7 @@
             Action("Use display list", "D", self.compile, noAnimation=1),
            SlideLin("seed", 42, 1, "seed number", "A", "a"),
            SlideLin("seed2", 42, 1, "highlihght seed number", "Z", "z"),
+           Toggle("path2", 0, "length-2 path", "2"),
             *light3d.commonkeys
        )
         self.list = None
@@ -125,15 +126,36 @@
             b["conns"].append(node["cs"])
 
         rng = Random(self.seed2 * 77)
-        x = rng.choice(nodes)
-        hl = [x, x]
-        while hl[0] == hl[1]:
-            hl[1] = rng.choice(nodes)
-        
+        nodes0 = nodes
+        while nodes0:
+            x = rng.choice(nodes0)
+
+            def p2(x, y):
+                return filter(lambda z: z in y["conns"], x["conns"])
+
+            nodes1 = filter(lambda y: y != x and y["cs"] not in x["conns"],
+                            nodes)
+
+            if self.path2:
+                nodes2 = filter(lambda y: p2(x, y), nodes1)
+            else:
+                nodes2 = filter(lambda y: not p2(x, y), nodes1)
+
+            if nodes2: break
+
+            nodes0 = filter(lambda y: x != y, nodes0)
+
+        if nodes2:
+            y = rng.choice(nodes2)
+        else:
+            print "Cannot find a pair of nodes of the requested type!!"
+            y = None
+                
+
        def pc(conns, cs):
             for node in nodes:
                 if node["conns"]:
-                    if node in hl:
+                    if node in [x, y]:
                         vs.put(getDListNocoords("Color 1 0 0"))
                     else:
                         vs.put(getDListNocoords("Color .2 .2 1"))




reply via email to

[Prev in Thread] Current Thread [Next in Thread]