/[fenfire]/fenfire/org/fenfire/util/lava/Traversals.test
ViewVC logotype

Diff of /fenfire/org/fenfire/util/lava/Traversals.test

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by tuukkah, Sat Aug 16 00:11:30 2003 UTC revision 1.3 by tuukkah, Sat Aug 16 11:45:39 2003 UTC
# Line 52  def testIsConnected(): Line 52  def testIsConnected():
52    
53    
54  def testfindComponents():  def testfindComponents():
55        def getNodes(fen):
56            return fen.constgraph.findN_XAA_Iter() # not realistic!
57    
58      fen = ff.test.fen.newFen()      fen = ff.test.fen.newFen()
59      p = ff.swamp.Nodes.N()      p = ff.swamp.Nodes.N()
60      q = ff.swamp.Nodes.N()      q = ff.swamp.Nodes.N()
# Line 65  def testfindComponents(): Line 68  def testfindComponents():
68      fen.graph.add(a,q,b)      fen.graph.add(a,q,b)
69      fen.graph.add(c,q,d)      fen.graph.add(c,q,d)
70    
71      ## no XAA problem if all nodes are subjects      # no XAA problem in getNodes if all nodes are subjects
72      # fen.graph.add(b,q,c)      fen.graph.add(b,q,c)
73      # fen.graph.add(d,q,a)      fen.graph.add(d,q,a)
74    
75      result = Traversals.findComponents(p, fen.constgraph)      result = Traversals.findComponents(getNodes(fen), p, fen.constgraph)
     nodes = fen.constgraph.findN_XAA_Iter()  
     print "XAA doesn't find objects:"  
     while nodes.hasNext():  
         print nodes.next()  
     print result  
76      for x in a, b, c, d:          # all single nodes are components      for x in a, b, c, d:          # all single nodes are components
77          assert result.contains(x)          assert result.contains(x)
78    
79      fen.graph.add(a,p,b)      fen.graph.add(a,p,b)
80    
81      result = Traversals.findComponents(p, fen.constgraph)      result = Traversals.findComponents(getNodes(fen), p, fen.constgraph)
82      assert result.contains(a) != result.contains(b) # Either is representative      assert result.contains(a) != result.contains(b) # Either is representative
83    
84      fen.graph.add(a,p,c)      fen.graph.add(a,p,c)
85    
86      result = Traversals.findComponents(p, fen.constgraph)      result = Traversals.findComponents(getNodes(fen), p, fen.constgraph)
87      assert result.contains(a)     # a has higher degree than b or c      assert result.contains(a)     # a has higher degree than b or c
88      assert not result.contains(b)      assert not result.contains(b)
89      assert not result.contains(c)      assert not result.contains(c)
# Line 93  def testfindComponents(): Line 91  def testfindComponents():
91      fen.graph.add(c,p,b)      fen.graph.add(c,p,b)
92      fen.graph.add(d,p,b)      fen.graph.add(d,p,b)
93    
94      result = Traversals.findComponents(p, fen.constgraph)      result = Traversals.findComponents(getNodes(fen), p, fen.constgraph)
95      assert result.contains(b)         # b has highest degree      assert result.contains(b)         # b has highest degree
96      for x in a, c, d:      for x in a, c, d:
97          assert not result.contains(x)          assert not result.contains(x)

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26