Changeset 5c28402 in tol


Ignore:
Timestamp:
Nov 9, 2009, 10:20:45 AM (17 years ago)
Author:
Víctor de Buen <vdebuen@…>
Branches:
1941-docker-image-to-test, devel, master
Children:
71426bc
Parents:
3affc27
Message:

Using new TripletUnique to avoid repeated edges

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tol_pkg/GraphTools/_GraphTools.tol

    r3affc27 r5c28402  
    220220  VMatrix _.edge.map = Rand(0,0,0,0);
    221221  VMatrix _.edge.adjacency = Rand(0,0,0,0);
     222  VMatrix _.edge.rep = Rand(0,0,0,0);
    222223  Real _.edge.check.rep = ?;
    223224
    … …  
    263264    Matrix in   = If(_.directed, in_,  Max(in_, out_));
    264265    Matrix _.edge::_.data := out | in | SubCol(data,Range(3,Columns(data),1));
     266
    265267    Matrix idx = DifEq(1/(1-B),Rand(_.edge.num,1,1,1));
    266     VMatrix triplet = Triplet(out|in|idx,_.vertex.num,_.vertex.num);
    267     VMatrix _.edge.map := Convert(triplet,"Cholmod.R.Sparse");
    268268    Matrix idx.rep = Rand(_.edge.num,1,1,1);
    269     VMatrix triplet.rep = Triplet(out|in|idx.rep,_.vertex.num,_.vertex.num);
    270     VMatrix _.edge.adjacency := Convert(triplet.rep,"Cholmod.R.Sparse");
    271     Real _.edge.check.rep := VMatMax(_.edge.adjacency)>1;
    272     If(_.edge.check.rep,
     269    Matrix outInRep = out|in|idx.rep;
     270    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,
     274    {
     275      VMatrix _.edge.adjacency := _.edge.rep;
     276      Triplet(out|in|idx,_.vertex.num,_.vertex.num)
     277    },
    273278    {
    274279      WriteLn("[GraphTools::@Graph "+_.name+"::edge.build()] "+
    275               "There are repeated edges","W")
     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)
    276284    });
     285    VMatrix _.edge.map := Convert(triplet.map,"Cholmod.R.Sparse");
    277286    True
    278287  };
    … …  
    335344    Real in   = If(_.directed, in_,  Max(in_, out_));
    336345    Real edge.idx = VMatDat(_.edge.map, out, in);
    337     edge.idx / VMatDat(_.edge.adjacency, out, in)
     346    edge.idx
    338347  };
    339348
Note: See TracChangeset for help on using the changeset viewer.