Changeset e7af41b in tol for tol_pkg/GraphTools
- Timestamp:
- Nov 9, 2009, 1:57:31 PM (17 years ago)
- Branches:
- 1941-docker-image-to-test, devel, master
- Children:
- 2720097
- Parents:
- ea1b10f
- Location:
- tol_pkg/GraphTools
- Files:
-
- 3 edited
-
_GraphTools.tol (modified) (4 diffs)
-
test/test_0001/define.random.graph.tol (modified) (3 diffs)
-
test/test_0001/test.tol (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tol_pkg/GraphTools/_GraphTools.tol
rea1b10f re7af41b 9 9 ////////////////////////////////////////////////////////////////////////////// 10 10 [[ 11 12 Text _.autodoc.description = "Functions and classes related with " 13 "Graph Theory."; 14 15 Text _.autodoc.keywords = "Graph Theory,vertex,edge,adjacent"; 16 11 17 ////////////////////////////////////////////////////////////////////////////// 12 18 Text _.autodoc.member.Append.Indexed = "Adds and index a new element to a " … … 220 226 VMatrix _.edge.map = Rand(0,0,0,0); 221 227 VMatrix _.edge.adjacency = Rand(0,0,0,0); 222 VMatrix _.edge.rep = Rand(0,0,0,0);223 Real _.edge.check.rep = ?;224 228 VMatrix _.edge.repeated = Rand(0,0,0,0); 229 Real _.edge.check.repeated = ?; 230 Real _.edge.check.repaired = ?; 225 231 //////////////////////////////////////////////////////////////////////////// 226 232 Static Text _.autodoc.member.New = "Creates a new instance of " … … 255 261 //////////////////////////////////////////////////////////////////////////// 256 262 Text _.autodoc.member.edge.build = ""; 257 Real edge.build(Matrix data )263 Real edge.build(Matrix data, Real removeRepeatedEdges) 258 264 //////////////////////////////////////////////////////////////////////////// 259 265 { … … 264 270 Matrix in = If(_.directed, in_, Max(in_, out_)); 265 271 Matrix _.edge::_.data := out | in | SubCol(data,Range(3,Columns(data),1)); 266 267 272 Matrix idx = DifEq(1/(1-B),Rand(_.edge.num,1,1,1)); 268 273 Matrix idx.rep = Rand(_.edge.num,1,1,1); 269 274 Matrix outInRep = out|in|idx.rep; 270 275 VMatrix triplet.rep = Triplet(outInRep,_.vertex.num,_.vertex.num); 271 VMatrix _.edge.rep := Convert(triplet.rep,"Cholmod.R.Sparse"); 272 Real _.edge.check.rep := VMatMax(_.edge.rep)>1; 273 VMatrix triplet.map = If(!_.edge.check.rep, 276 VMatrix _.edge.repeated := Convert(triplet.rep,"Cholmod.R.Sparse"); 277 VMatrix _.edge.adjacency := Or(_.edge.repeated, Zeros(_.vertex.num)); 278 VMatrix _.edge.repeated := _.edge.repeated - _.edge.adjacency; 279 Real _.edge.check.repeated := VMatSum(_.edge.repeated); 280 Code funTriplet = Case( 281 !_.edge.check.repeated, 274 282 { 275 VMatrix _.edge.adjacency := _.edge.rep;276 Triplet (out|in|idx,_.vertex.num,_.vertex.num)283 Real _.edge.check.repaired := 0; 284 Triplet 277 285 }, 286 removeRepeatedEdges, 278 287 { 279 288 WriteLn("[GraphTools::@Graph "+_.name+"::edge.build()] "+ 280 "There are repeated edges","W"); 281 VMatrix triplet.adj = TripletUnique(outInRep,_.vertex.num,_.vertex.num); 282 VMatrix _.edge.adjacency := Convert(triplet.adj,"Cholmod.R.Sparse"); 283 TripletUnique(out|in|idx,_.vertex.num,_.vertex.num) 289 "There was "<<_.edge.check.repeated+ 290 " repeated edges that has been removed","W"); 291 Real _.edge.check.repaired := _.edge.check.repeated; 292 TripletUnique 293 }, 294 1==1, 295 { 296 WriteLn("[GraphTools::@Graph "+_.name+"::edge.build()] "+ 297 "There are "<<_.edge.check.repeated+" repeated edges " 298 "but they don't will be deleted","W"); 299 Real _.edge.check.repaired := 0; 300 Triplet 284 301 }); 302 VMatrix triplet.map = funTriplet(out|in|idx,_.vertex.num,_.vertex.num); 285 303 VMatrix _.edge.map := Convert(triplet.map,"Cholmod.R.Sparse"); 286 304 True -
tol_pkg/GraphTools/test/test_0001/define.random.graph.tol
rea1b10f re7af41b 5 5 6 6 //Random seed setting 7 Real PutRandomSeed(0); 8 Real rndSeed = GetRandomSeed(0); 7 Real If(ObjectExist("Real","rndSeed"), 8 PutRandomSeed(rndSeed), 9 PutRandomSeed(0)); 10 Real If(ObjectExist("Real","rndSeed"), rndSeed, 11 rndSeed = GetRandomSeed(0)); 12 9 13 WriteLn("Current Random Seed = "<<rndSeed); 10 14 11 Real vertex.num = IntRand(2,1000); 12 Real edge.num = IntRand(1,(vertex.num)^1.6); 13 Real directed = IntRand(0,1); 15 16 Real If(ObjectExist("Real","vertex.num"), vertex.num, 17 vertex.num = IntRand(2,100) ); 18 Real If(ObjectExist("Real","edge.num"), edge.num, 19 edge.num = IntRand(1,(vertex.num)^1.6) ); 20 Real If(ObjectExist("Real","directed"), directed, 21 directed = IntRand(0,1) ); 22 Real If(ObjectExist("Real","removeRepeatedEdges"), removeRepeatedEdges, 23 removeRepeatedEdges = IntRand(0,1) ); 14 24 15 25 WriteLn("Creating "+If(directed,"directed","symmetric")+ … … 17 27 edge.num+" edges ..."); 18 28 Real t0 = Copy(Time); 19 20 29 21 30 GraphTools::@Graph graph = GraphTools::@Graph::New("test_0001",directed); … … 37 46 { Hight = Rand(edge.num, 1, 1, 10) }; 38 47 39 Real graph::edge.build(data );48 Real graph::edge.build(data,removeRepeatedEdges); 40 49 50 Real t1 = Copy(Time); 51 52 WriteLn("Creating time "<<(t1-t0)+" seconds"); -
tol_pkg/GraphTools/test/test_0001/test.tol
rea1b10f re7af41b 12 12 Real numWar0 = Copy(NWarning); 13 13 14 Real rndSeed = 0; 15 Real removeRepeatedEdges = True; 14 16 15 17 #Embed "../../_GraphTools.tol";
Note: See TracChangeset
for help on using the changeset viewer.
