| [17c9671] | 1 | /* -*- mode: C++ -*- */ |
|---|
| 2 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 3 | // FILE : test.tol |
|---|
| 4 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 5 | Text email_ = "vdebuen@tol-project.org"; |
|---|
| [2b60aab] | 6 | Text link_ = ""; |
|---|
| [17c9671] | 7 | Text summary_ = "checking a simple graph"; |
|---|
| 8 | |
|---|
| 9 | //Write here the initial test TOL code if needed |
|---|
| 10 | Real numErr0 = Copy(NError); |
|---|
| 11 | Real numWar0 = Copy(NWarning); |
|---|
| 12 | |
|---|
| [e7af41b] | 13 | Real rndSeed = 0; |
|---|
| 14 | Real removeRepeatedEdges = True; |
|---|
| [17c9671] | 15 | |
|---|
| [01f6b1c7] | 16 | #Require GraphTools; |
|---|
| [cf0e0df] | 17 | #Embed "../define.random.graph.tol"; |
|---|
| [f7b99ac] | 18 | |
|---|
| [48755f1] | 19 | Set vertex.names_ = graph::get.vertex.names(?); |
|---|
| 20 | |
|---|
| 21 | Real ok.1 = Card(vertex.names)==Card(vertex.names_); |
|---|
| 22 | |
|---|
| 23 | Real vertex.idx = IntRand(1,vertex.num); |
|---|
| 24 | |
|---|
| 25 | Text vertex.name_ = graph::get.vertex.name(vertex.idx); |
|---|
| 26 | Real ok.2 = vertex.name_==vertex.names[vertex.idx]; |
|---|
| 27 | |
|---|
| [b88d5e3] | 28 | Real edge.idx = |
|---|
| 29 | { |
|---|
| 30 | Real aux = IntRand(1,edge.num); |
|---|
| 31 | Set info = graph::get.edge.features(aux); |
|---|
| 32 | graph::get.edge.index(info[1], info[2]) |
|---|
| 33 | }; |
|---|
| 34 | |
|---|
| [48755f1] | 35 | Set edge.info = graph::get.edge.features(edge.idx); |
|---|
| [4d44f38] | 36 | Real edge.idx.1 = graph::get.edge.index(edge.info[1], edge.info[2]); |
|---|
| 37 | Real edge.idx.2 = graph::get.edge.index(edge.info[2], edge.info[1]); |
|---|
| [f7b99ac] | 38 | |
|---|
| 39 | WriteLn("edge.idx = "<<edge.idx); |
|---|
| 40 | WriteLn("edge.idx.1 = "<<edge.idx.1); |
|---|
| 41 | WriteLn("edge.idx.2 = "<<edge.idx.2); |
|---|
| 42 | |
|---|
| [3affc27] | 43 | Real ok.3_ = edge.idx.1==edge.idx; |
|---|
| 44 | Real ok.4_ = edge.idx.2==edge.idx; |
|---|
| 45 | |
|---|
| 46 | Real ok.3 = ?; |
|---|
| 47 | Real ok.4 = ?; |
|---|
| 48 | |
|---|
| 49 | Real If(directed, |
|---|
| 50 | { |
|---|
| 51 | Real ok.3 := ok.3_ | ok.4_; |
|---|
| 52 | Real ok.4 := ok.3_ | ok.4_ |
|---|
| 53 | }, |
|---|
| 54 | { |
|---|
| 55 | Real ok.3 := ok.3_; |
|---|
| 56 | Real ok.4 := ok.3_ |
|---|
| 57 | }); |
|---|
| [4d44f38] | 58 | |
|---|
| 59 | Real high = MatDat(data,edge.idx,4); |
|---|
| 60 | Real high.1 = graph::get.edge.feature(edge.idx,4); |
|---|
| 61 | Real high.2 = graph::get.edge.feature(edge.idx,"Hight"); |
|---|
| 62 | Real ok.5 = Eq(high,high.1,high.2); |
|---|
| 63 | |
|---|
| [b88d5e3] | 64 | Set { |
|---|
| 65 | Real OSFilRemove("graph.oza"); |
|---|
| 66 | Real t1 := Copy(Time); |
|---|
| 67 | WriteLn("Creating time "<<(t1-t0)+" seconds"); |
|---|
| 68 | Real Ois.Store([[graph]],"graph.oza"); |
|---|
| 69 | Real t2 = Copy(Time); |
|---|
| 70 | WriteLn("Saving OIS time "<<(t2-t1)+" seconds"); |
|---|
| 71 | Set load = { Include("graph.oza") }; |
|---|
| 72 | Real t3 = Copy(Time); |
|---|
| 73 | WriteLn("Loading OIS time "<<(t3-t2)+" seconds"); |
|---|
| 74 | load |
|---|
| 75 | }; |
|---|
| [17c9671] | 76 | |
|---|
| 77 | |
|---|
| 78 | Real numErr1 = Copy(NError); |
|---|
| 79 | Real numWar1 = Copy(NWarning); |
|---|
| 80 | |
|---|
| [2b60aab] | 81 | Set partialResults_ = [[numErr0, numErr1, |
|---|
| [73a68a6] | 82 | ok.1, ok.2, ok.3, ok.4, ok.5]]; |
|---|
| [17c9671] | 83 | |
|---|
| 84 | //This is a messure of the success of the test |
|---|
| 85 | Real quality_ = And(numErr1 == numErr0, |
|---|
| [48755f1] | 86 | numWar1 <= numWar0+1, |
|---|
| [73a68a6] | 87 | ok.1, ok.2, ok.3, ok.4, ok.5); |
|---|
| [17c9671] | 88 | |
|---|
| 89 | //Return the results |
|---|
| 90 | Set resultStr_ = @strTestStatus(summary_, link_, quality_, |
|---|
| 91 | "Partial results = "<<partialResults_, |
|---|
| 92 | "NO DBServerType", "NO DBServerHost", "NO DBAlias", |
|---|
| 93 | email_); |
|---|
| 94 | WriteLn(""<<resultStr_); |
|---|
| [b88d5e3] | 95 | resultStr_ |
|---|
| [17c9671] | 96 | |
|---|
| 97 | /* */ |
|---|
| 98 | |
|---|