source: tol/tol_pkg/GraphTools/test/test_0002/test.tol @ aa1e2cc

1941-docker-image-to-testdevel
Last change on this file since aa1e2cc was aa1e2cc, checked in by Víctor de Buen <vdebuen@…>, 17 years ago

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1737 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/* -*- mode: C++ -*- */
2//////////////////////////////////////////////////////////////////////////////
3// FILE   : test.tol
4//////////////////////////////////////////////////////////////////////////////
5Text email_ = "vdebuen@tol-project.org";
6Text link_ = "";
7Text summary_ = "checking a simple graph";
8
9  #Require GraphTools;
10//#Embed "../../../_embed_all.tol";
11
12//Write here the initial test TOL code if needed
13Real numErr0 = Copy(NError);
14Real numWar0 = Copy(NWarning);
15
16Real rndSeed = 0;
17Real vertex.num = 1000;
18Real edge.num = 20000;
19Real removeRepeatedEdges = True;
20
21#Embed "../define.random.graph.tol";
22
23Real vertex.idx  = IntRand(1,vertex.num);
24Text vertex.name = graph::get.vertex.name(vertex.idx);
25
26//The number of edges whose output is the selected vertex
27Real vertex.in.deg   = graph::vertex.in.degree(vertex.idx);
28
29//The number of edges whose input is the selected vertex
30Real vertex.out.deg  = graph::vertex.out.degree(vertex.idx);
31
32//Returns an sparse column matrix with True in all edges which Output is the
33//specified vertex
34VMatrix edge.match.in = graph::_.edge::match.feature.with.value(
35  "Output", vertex.idx);
36
37//We can obtain the selected set of edges as 
38Set edge.in = MatQuery::SelectMatch(edge.match.in);
39
40//Returns an sparse column matrix with True in all edges which Length is in
41//the interval [20,30] both included
42VMatrix edge.match.length = graph::_.edge::match.feature.in.interval(
43  "Length", True, 0, 70, True);
44
45//Logic operations are faster in sparse matrix when there are no much non
46//zero cells
47VMatrix edge.match.all = And(edge.match.in, edge.match.length);
48
49//We can obtain the selected set of edges as 
50Set edge.select = MatQuery::SelectMatch(edge.match.all);
51
52//If we want another feature of selected edges as the input nodes
53VMatrix in.select=graph::_.edge::extract.feature.rows("Input",edge.select);
54
55//Checks the number of inputs is the input degree
56Real ok.1 = VMatSum(edge.match.in) == vertex.in.deg;
57//Checks that edge.select is a subset of edge.in
58Real ok.2 = Card((edge.select * edge.in) - edge.select)==0;
59
60Real numErr1 = Copy(NError);
61Real numWar1 = Copy(NWarning);
62
63Set partialResults_ = [[numErr0, numErr1,
64                        ok.1, ok.2]];
65
66//This is a messure of the success of the test
67Real quality_ = And(numErr1 == numErr0,
68                    numWar1 <= numWar0+1,
69                    ok.1, ok.2);
70
71//Return the results
72Set resultStr_ = @strTestStatus(summary_, link_, quality_,
73                  "Partial results = "<<partialResults_,
74                  "NO DBServerType", "NO DBServerHost", "NO DBAlias",
75                  email_);
76WriteLn(""<<resultStr_);
77resultStr_
78
79/* */
80
Note: See TracBrowser for help on using the repository browser.