#include "grhdr.h"
/******************************************************************************
Chu-Liu-Edmonds algorithm to compute a maximum branching for a
directed graph with edge weights. The algorithm alters the edge
lists to contain just the branching edges.
Written by Kiem-Phong Vo (02/01/2006)
******************************************************************************/
typedef struct _brcycl_s
} Brcycl_t;
typedef struct _brnode_s
} Brnode_t;
typedef struct _bredge_s
} Bredge_t;
/* compute the representative node in the shadowed union structure */
{ while(n->link != n)
n = n->link;
return n;
}
#ifdef DEBUG
{
if(!ed)
return 0;
}
return 0;
}
{ for(; e; e = e->link)
}
{ for(; e; e = e->inext)
}
{ for(; e; e = e->onext)
}
{
if(!nd)
return 0;
}
return 0;
}
{
}
{
Gredge_t *e;
return 0;
}
continue;
}
}
#endif
{
ssize_t w;
/* compute heaviest weight ec and move it to front */
}
if(ep)
}
if(w == 0)
return 0;
/* space to keep cycle structures */
return -1;
/* search and collapse cycles */
continue;
break;
else /* continue to build the path */
continue; /* dfs recursion */
}
}
/* potential cycle, check that out and also compute min edge */
break;
}
if(!ec) /* run up against an old path */
break;
return -1;
}
/* make list of incoming edges and adjust their weights */
if(!e->inext) /* last of list */
ep = e;
}
}
/* collapsing cycle onto nc */
continue;
}
/* make new edge list, keep heaviest edge in front */
continue;
}
cl += 1;
}
}
/* move the remaining branching edges to their real nodes */
{ if(!(e = n->iedge) )
continue;
}
/* unroll collapsed cycles in reverse order to construct branching */
{ /* restore the union structure to just before this cycle collapsed */
}
if(!en) /* isolated cycle, remove minimum edge */
}
}
w = 0; /* construct the external branching representation */
{ if(!(e = n->iedge) )
continue;
}
return w;
}
{
if(w > 0)
}
{
if(algo != Grbranching)
switch(type)
{ default:
case GR_NODE|GR_CLOSING:
case GR_EDGE|GR_CLOSING:
if(data)
case GR_NODE|GR_OPENING:
case GR_EDGE|GR_OPENING:
}
}
#ifdef KPVTEST
#include <stdio.h>
{
Gredge_t *e;
int h, t, w;
int type = 0;
type = -1;
type = 1;
{ if(buf[0] == '#')
continue;
continue;
if(type > 0 && t >= h) /* only use edges with t < h */
continue;
if(type < 0 && t <= h) /* only use edges with t > h */
continue;
grbrweight(e, w);
}
if((e = n->iedge) )
}
#endif