148{
PORD_INT *ncolfactor, *ncolupdate, *parent, *firstchild, *silbings, *vtx2front;
149 PORD_INT *first, *link, nvtx, nfronts,
root, J, K, u, count, child;
161 printf(
"#fronts %d, root %d\n", nfronts,
root);
169 for (J = 0; J < nfronts; J++)
171 for (u = nvtx-1; u >= 0; u--)
181 { printf(
"--- front %d, ncolfactor %d, ncolupdate %d, parent %d\n",
182 K, ncolfactor[K], ncolupdate[K], parent[K]);
184 printf(
"children:\n");
185 for (child = firstchild[K]; child != -1; child = silbings[child])
186 { printf(
"%5d", child);
187 if ((++count % 16) == 0)
190 if ((count % 16) != 0)
193 printf(
"vertices mapped to front:\n");
194 for (u = first[K]; u != -1; u = link[u])
196 if ((++count % 16) == 0)
199 if ((count % 16) != 0)
206 free(first); free(link);
218 if ((J = T->
root) != -1)
219 while (firstchild[J] != -1)
233 if ((J =
root) != -1)
234 while (firstchild[J] != -1)
244{
PORD_INT *parent, *firstchild, *silbings;
250 if (silbings[J] != -1)
252 while (firstchild[J] != -1)
273{
PORD_INT *parent, *firstchild, *silbings;
279 if (firstchild[J] != -1)
282 {
while ((silbings[J] == -1) && (parent[J] != -1))
296 PORD_INT *xadj, *adjncy, *vwght, *ncolfactor, *ncolupdate, *parent;
297 PORD_INT *vtx2front, *realroot, *uf_father, *uf_size;
299 PORD_INT nvtx, front, front2, froot, f,
r, u, v, i, istart, istop;
326 for (front = 0; front < nvtx; front++)
327 { parent[front] = -1;
329 uf_father[front] = front;
331 realroot[front] = front;
337 for (i = istart; i < istop; i++)
343 while (uf_father[
r] !=
r)
347 front2 = uf_father[front2];
352 if ((parent[f] == -1) && (f != front))
354 if (uf_size[froot] < uf_size[
r])
355 { uf_father[froot] =
r;
356 uf_size[
r] += uf_size[froot];
360 { uf_father[
r] = froot;
361 uf_size[froot] += uf_size[
r];
363 realroot[froot] = front;
383 for (front = 0; front < nvtx; front++)
385 ncolfactor[front] = vwght[u];
386 ncolupdate[front] = 0;
387 vtx2front[u] = front;
388 len = xnzl[front+1] - xnzl[front];
389 if (prevlen - 1 == len)
390 ncolupdate[front] = ncolupdate[front-1] - vwght[u];
392 { h = xnzlsub[front] + 1;
393 for (i = 1; i < len; i++)
394 { hsub = nzlsub[h++];
396 ncolupdate[front] += vwght[v];
406 free(realroot); free(uf_father); free(uf_size);
415{
PORD_INT *parent, *firstchild, *silbings, nfronts, J, pJ;
422 for (J = 0; J < nfronts; J++)
423 silbings[J] = firstchild[J] = -1;
425 for (J = nfronts-1; J >= 0; J--)
426 if ((pJ = parent[J]) != -1)
427 { silbings[J] = firstchild[pJ];
431 { silbings[J] = T->
root;
441{
PORD_INT *vtx2front, *first, *link;
442 PORD_INT nvtx, nfronts, K, u, count;
454 for (K = 0; K < nfronts; K++)
456 for (u = nvtx-1; u >= 0; u--)
468 for (u = first[K]; u != -1; u = link[u])
476 free(first); free(link);
496 for (J = 0; J < nfronts; J++)
507 for (u = 0; u < nvtx; u++)
530 for (J = 0; J < nfronts; J++)
543 for (u = 0; u < nvtxorg; u++)
544 vtx2front2[u] = vtx2front[vtxmap[u]];
555 PORD_INT *ncolfactor, *ncolupdate, *parent, *firstchild, *silbings;
556 PORD_INT *frontmap, nfronts, cnfronts, J, child;
576 {
while (firstchild[J] != -1)
578 frontmap[J] = cnfronts++;
579 while ((silbings[J] == -1) && (parent[J] != -1))
581 child = firstchild[J];
582 if ((silbings[child] != -1)
583 || (ncolupdate[child] != ncolfactor[J] + ncolupdate[J]))
584 frontmap[J] = cnfronts++;
586 frontmap[J] = frontmap[child];
609 PORD_INT *ncolfactor, *ncolupdate, *firstchild, *silbings;
610 PORD_INT *frontmap, *newncolfactor, *nzeros, *rep;
611 PORD_INT nfronts, cnfronts, K, ncolfrontK, J, Jall, cost;
626 for (K = 0; K < nfronts; K++)
627 { newncolfactor[K] = ncolfactor[K];
636 if (firstchild[K] != -1)
637 { ncolfrontK = newncolfactor[K] + ncolupdate[K];
640 for (J = firstchild[K]; J != -1; J = silbings[J])
641 { Jall += newncolfactor[J];
642 cost -= newncolfactor[J] * newncolfactor[J];
643 cost += 2*newncolfactor[J] * (ncolfrontK - ncolupdate[J]);
649 {
for (J = firstchild[K]; J != -1; J = silbings[J])
651 newncolfactor[K] += newncolfactor[J];
661 for (K = 0; K < nfronts; K++)
663 frontmap[K] = cnfronts++;
665 {
for (J = K; rep[J] != J; J = rep[J]);
668 for (K = 0; K < nfronts; K++)
669 if ((J = rep[K]) != K)
670 frontmap[K] = frontmap[J];
680 free(frontmap); free(newncolfactor);
681 free(nzeros); free(rep);
691 PORD_INT *ncolfactor, *ncolupdate, *parent, *vtx2front;
692 PORD_INT nvtx, nfronts, u, K, pK, newfront, pnewfront;
706 for (K = 0; K < cnfronts; K++)
714 for (K = 0; K < nfronts; K++)
715 { newfront = frontmap[K];
717 if (((pK = parent[K]) != -1)
718 && ((pnewfront = frontmap[pK]) != newfront))
719 { T2->
parent[newfront] = pnewfront;
732 for (u = 0; u < nvtx; u++)
733 T2->
vtx2front[u] = frontmap[vtx2front[u]];
742{
PORD_INT *ncolfactor, *ncolupdate, *firstchild, *silbings, *minWspace, *list;
743 PORD_INT nfronts, K, ncolfrontK, frontsizeK, wspace, child, nxtchild;
764 { ncolfrontK = ncolfactor[K] + ncolupdate[K];
765 frontsizeK = (ncolfrontK * (ncolfrontK + 1)) >> 1;
767 if ((child = firstchild[K]) == -1)
768 minWspace[K] = frontsizeK;
774 { list[count++] = child;
775 child = silbings[child];
779 for (i = 0; i < count; i++)
781 silbings[child] = firstchild[K];
782 firstchild[K] = child;
786 child = firstchild[K];
787 nxtchild = silbings[child];
788 m = s = minWspace[child];
789 while (nxtchild != -1)
790 { s = s - minWspace[child]
791 + ((ncolupdate[child] * (ncolupdate[child] + 1)) >> 1)
792 + minWspace[nxtchild];
795 nxtchild = silbings[nxtchild];
797 s = s - minWspace[child]
798 + ((ncolupdate[child] * (ncolupdate[child] + 1)) >> 1)
800 minWspace[K] =
max(m, s);
803 wspace =
max(wspace, minWspace[K]);
809 free(minWspace); free(list);
818{
PORD_INT *ncolfactor, *ncolupdate, *firstchild, *silbings, *minWspace;
819 PORD_INT nfronts, K, ncolfrontK, frontsizeK, wspace, child, nxtchild, m, s;
837 { ncolfrontK = ncolfactor[K] + ncolupdate[K];
838 frontsizeK = (ncolfrontK * (ncolfrontK + 1)) >> 1;
840 if ((child = firstchild[K]) == -1)
841 minWspace[K] = frontsizeK;
843 { child = firstchild[K];
844 nxtchild = silbings[child];
845 m = s = minWspace[child];
846 while (nxtchild != -1)
847 { s = s - minWspace[child]
848 + ((ncolupdate[child] * (ncolupdate[child] + 1)) >> 1)
849 + minWspace[nxtchild];
852 nxtchild = silbings[nxtchild];
854 s = s - minWspace[child]
855 + ((ncolupdate[child] * (ncolupdate[child] + 1)) >> 1)
857 minWspace[K] =
max(m, s);
860 wspace =
max(wspace, minWspace[K]);
883 for (K = 0; K < nfronts; K++)
884 ind += (ncolfactor[K] + ncolupdate[K]);
901 { tri = ncolfactor[K];
903 ent += (tri * (tri+1)) / 2;
923 { tri = ncolfactor[K];
925 ops += (tri*tri*tri) / 3.0 + (tri*tri) / 2.0 - (5*tri) / 6.0;
926 ops += (tri*tri*rec) + (rec*(rec+1)*tri);
944 { tri = ncolfactor[K];
946 ops[K] = (tri*tri*tri) / 3.0 + (tri*tri) / 2.0 - (5*tri) / 6.0;
947 ops[K] += (tri*tri*rec) + (rec*(rec+1)*tri);
967 { tri = ncolfactor[K];
969 ops += (tri*tri) + 2.0*tri*rec;
970 ops += (tri*tri) + 2.0*tri*rec;
#define mymalloc(ptr, nr, type)
css_t * setupCSSFromGraph(graph_t *, PORD_INT *, PORD_INT *)
void insertUpIntsWithStaticIntKeys(PORD_INT, PORD_INT *, PORD_INT *)
PORD_INT firstPostorder2(elimtree_t *T, PORD_INT root)
void printElimTree(elimtree_t *T)
elimtree_t * setupElimTree(graph_t *G, PORD_INT *perm, PORD_INT *invp)
elimtree_t * fundamentalFronts(elimtree_t *T)
PORD_INT justifyFronts(elimtree_t *T)
elimtree_t * mergeFronts(elimtree_t *T, PORD_INT maxzeros)
void subtreeFactorOps(elimtree_t *T, FLOAT *ops)
PORD_INT nFactorIndices(elimtree_t *T)
elimtree_t * expandElimTree(elimtree_t *T, PORD_INT *vtxmap, PORD_INT nvtxorg)
void permFromElimTree(elimtree_t *T, PORD_INT *perm)
elimtree_t * newElimTree(PORD_INT nvtx, PORD_INT nfronts)
FLOAT nFactorOps(elimtree_t *T)
PORD_INT firstPostorder(elimtree_t *T)
FLOAT nTriangularOps(elimtree_t *T)
elimtree_t * compressElimTree(elimtree_t *T, PORD_INT *frontmap, PORD_INT cnfronts)
PORD_INT nWorkspace(elimtree_t *T)
void freeElimTree(elimtree_t *T)
void initFchSilbRoot(elimtree_t *T)
elimtree_t * permuteElimTree(elimtree_t *T, PORD_INT *perm)
PORD_INT nFactorEntries(elimtree_t *T)
PORD_INT firstPreorder(elimtree_t *T)
PORD_INT nextPostorder(elimtree_t *T, PORD_INT J)
PORD_INT nextPreorder(elimtree_t *T, PORD_INT J)
struct _elimtree elimtree_t