Skip to content

Commit 9cae706

Browse files
committed
Debugged SCC algorithm + Nomenclature
1 parent bf7cd4e commit 9cae706

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

sbg/sbg_algorithms.cpp

+21-21
Original file line numberDiff line numberDiff line change
@@ -542,52 +542,52 @@ PWMap<Set> SBGSCC<Set>::sccMinReach(DSBGraph<Set> dg) const
542542
if (!vs.isEmpty()) {
543543
// Vertices in the set-vertex that share its rep with other vertex
544544
// in the set-vertex
545-
Set rec_vs = rmap.restrict(vs).sharedImage();
545+
Set VR = rmap.restrict(vs).sharedImage();
546546
// There is a recursive vertex that changed its rep in the last step
547547
// (to avoid computing again an already found recursion)
548-
if (!rec_vs.intersection(Vc).isEmpty()) {
549-
// Vertices that reach the same rep as rec_vs
550-
Set same_rep = rmap.preImage(rmap.image(rec_vs));
551-
Set same_SV = dg.Vmap().preImage(dg.Vmap().image(same_rep));
552-
// Edges with both endings in same_rep (path to a minimum rep)
553-
Set esB = mapB.preImage(same_rep), esD = mapD.preImage(same_rep);
554-
Set es = esB.intersection(esD);
548+
if (!VR.intersection(Vc).isEmpty()) {
549+
// Edges with both endings in VR (path to a minimum rep)
550+
Set ERB = mapB.preImage(VR), ERD = mapD.preImage(VR);
551+
Set ER = ERB.intersection(ERD);
555552

556553
// Distance map
557554
PW dmap;
558-
Set reps = rmap.image(), ith = reps.intersection(same_rep), visited;
555+
Set ith = rmap.image(VR), dom_VR;
556+
//Set visited, dom_vs;
559557
unsigned int copies = mapB.nmbrDims();
560558
Util::NAT dist = 0;
561559
// Calculate distance for vertices in same_rep that reach reps
562-
for (Set ith; !ith.intersection(same_rep).isEmpty();) {
560+
for (; dg.Vmap().restrict(dom_VR).sharedImage().isEmpty();) {
563561
Exp exp(Util::MD_NAT(copies, dist));
564-
dmap.emplaceBack(Map(ith.difference(visited), exp));
562+
Set dom = ith.difference(dmap.dom());
563+
dmap.emplaceBack(Map(ith.difference(dmap.dom()), exp));
564+
dom_VR = dmap.dom().intersection(VR);
565565
// Update ith to vertices that have outgoing edges entering ith
566-
ith = mapB.image(mapD.preImage(ith)).intersection(same_rep);
567-
visited = visited.cup(ith);
566+
ith = mapB.image(mapD.preImage(ith));
568567
++dist;
569568
}
569+
dmap = dmap.restrict(VR);
570570
PW dmapB = dmap.composition(mapB), dmapD = dmap.composition(mapD);
571571
// Get edges where the end is closer to the rep that the beginning
572572
Set not_cycle_edges = dmapB.gtImage(dmapD);
573-
es = es.intersection(not_cycle_edges);
573+
ER = ER.intersection(not_cycle_edges);
574574

575575
// Extend to subset-edge
576-
Set es_plus = subE_map.preImage(subE_map.image(es));
577-
PW auxB = mapB.restrict(es_plus), auxD = mapD.restrict(es_plus);
576+
Set ER_plus = subE_map.preImage(subE_map.image(ER));
577+
PW auxB = mapB.restrict(ER_plus), auxD = mapD.restrict(ER_plus);
578578
// Calculate a succesor
579+
Set same_SV = dg.Vmap().preImage(dg.Vmap().image(VR));
579580
PW rmap_plus = auxB.minAdjMap(auxD).restrict(same_SV);
580581

581-
// Leave original reps for same_rep and update reps for recursion
582-
rmap_plus = rmap.restrict(same_rep).combine(rmap_plus);
583582
// Update rmap for recursion, and leave the rest unchanged
584583
rec_rmap = rmap_plus.combine(rec_rmap).compact();
585584

586585
if (debug()) {
587-
Util::SBG_LOG << "same_rep: " << same_rep << "\n";
588-
Util::SBG_LOG << "es: " << es << "\n";
586+
Util::SBG_LOG << "VR: " << VR << "\n";
587+
Util::SBG_LOG << "ER: " << ER << "\n";
588+
Util::SBG_LOG << "dmap: " << dmap << "\n";
589589
Util::SBG_LOG << "not_cycle_edges: " << not_cycle_edges << "\n";
590-
Util::SBG_LOG << "es_plus: " << es_plus << "\n";
590+
Util::SBG_LOG << "ER_plus: " << ER_plus << "\n";
591591
Util::SBG_LOG << "rmap_plus: " << rmap_plus << "\n";
592592
}
593593
}

0 commit comments

Comments
 (0)