third_party/inchi/INCHI_BASE/src/ichirvr1.c
int AddEdgeFlow( int edge_cap, int edge_flow, BNS_EDGE *e01, BNS_VERTEX *pSrc /*src*/,
                  BNS_VERTEX *pDst/*dest*/, int *tot_st_cap, int *tot_st_flow )
{

    /* overflow check */
    if (e01->cap < 0 || edge_cap < 0 || (int) e01->cap + edge_cap >= EDGE_FLOW_MASK)
    {
        return BNS_PROGRAM_ERR;
    }

    if (pDst->st_edge.cap < 0 || (int) pDst->st_edge.cap + edge_cap >= EDGE_FLOW_ST_MASK ||
         pDst->st_edge.flow < 0 || (int) pDst->st_edge.flow + edge_flow >= EDGE_FLOW_ST_MASK ||
         pSrc->st_edge.cap < 0 || pSrc->st_edge.flow < 0 ||
         (int) pSrc->st_edge.flow + edge_flow >= EDGE_FLOW_ST_MASK)
    {
        return BNS_PROGRAM_ERR;
    }

    /* add flow */
    e01->cap += edge_cap;
    e01->flow += edge_flow;
    e01->cap0 = e01->cap;
    e01->flow0 = e01->flow;

    pDst->st_edge.cap += edge_cap;
    pDst->st_edge.cap0 = pDst->st_edge.cap;
    *tot_st_cap += edge_cap;

    pDst->st_edge.flow += edge_flow;
    pDst->st_edge.flow0 = pDst->st_edge.flow;
    *tot_st_flow += edge_flow;

    pSrc->st_edge.flow += edge_flow;
    pSrc->st_edge.flow0 = pSrc->st_edge.flow;
    *tot_st_flow += edge_flow;

/*
    pDst->st_edge.cap  += e01->cap;
    pDst->st_edge.cap0  = pDst->st_edge.cap;
    *tot_st_cap       += e01->cap;

    pDst->st_edge.flow += e01->flow;
    pDst->st_edge.flow0 = pDst->st_edge.flow;
    *tot_st_flow      += e01->flow;

    pSrc->st_edge.flow += e01->flow;
    pSrc->st_edge.flow0 = pSrc->st_edge.flow;
    *tot_st_flow      += e01->flow;
*/
    return 0;
}
/*********************************************************************************
  Add cap and flow to an edge
  Add edge flow to the source vertex st_flow
  Add edge cap & flow to the destination vertex cap and flow
 *********************************************************************************/
Add cap and flow to an edge
Add edge flow to the source vertex st_flow
Add edge cap & flow to the destination vertex cap and flow
Add cap and flow to an edge Add edge flow to the source vertex st_flow Add edge cap & flow to the destination vertex cap and flow
int AddEdgeFlow( int edge_cap, int edge_flow, BNS_EDGE *e01, BNS_VERTEX *pSrc ,
                  BNS_VERTEX *pDst, int *tot_st_cap, int *tot_st_flow )
{
    if (e01->cap < 0 || edge_cap < 0 || (int) e01->cap + edge_cap >= EDGE_FLOW_MASK)
    {
        return BNS_PROGRAM_ERR;
    }
    if (pDst->st_edge.cap < 0 || (int) pDst->st_edge.cap + edge_cap >= EDGE_FLOW_ST_MASK ||
         pDst->st_edge.flow < 0 || (int) pDst->st_edge.flow + edge_flow >= EDGE_FLOW_ST_MASK ||
         pSrc->st_edge.cap < 0 || pSrc->st_edge.flow < 0 ||
         (int) pSrc->st_edge.flow + edge_flow >= EDGE_FLOW_ST_MASK)
    {
        return BNS_PROGRAM_ERR;
    }
    e01->cap += edge_cap;
    e01->flow += edge_flow;
    e01->cap0 = e01->cap;
    e01->flow0 = e01->flow;
    pDst->st_edge.cap += edge_cap;
    pDst->st_edge.cap0 = pDst->st_edge.cap;
    *tot_st_cap += edge_cap;
    pDst->st_edge.flow += edge_flow;
    pDst->st_edge.flow0 = pDst->st_edge.flow;
    *tot_st_flow += edge_flow;
    pSrc->st_edge.flow += edge_flow;
    pSrc->st_edge.flow0 = pSrc->st_edge.flow;
    *tot_st_flow += edge_flow;
    return 0;
}
int AddEdgeFlow ( int edge_cap , int edge_flow , BNS_EDGE * e01 , BNS_VERTEX * pSrc , BNS_VERTEX * pDst , int * tot_st_cap , int * tot_st_flow ) { if ( e01 -> cap < 0 || edge_cap < 0 || ( int ) e01 -> cap + edge_cap >= EDGE_FLOW_MASK ) { return BNS_PROGRAM_ERR ; } if ( pDst -> st_edge . cap < 0 || ( int ) pDst -> st_edge . cap + edge_cap >= EDGE_FLOW_ST_MASK || pDst -> st_edge . flow < 0 || ( int ) pDst -> st_edge . flow + edge_flow >= EDGE_FLOW_ST_MASK || pSrc -> st_edge . cap < 0 || pSrc -> st_edge . flow < 0 || ( int ) pSrc -> st_edge . flow + edge_flow >= EDGE_FLOW_ST_MASK ) { return BNS_PROGRAM_ERR ; } e01 -> cap += edge_cap ; e01 -> flow += edge_flow ; e01 -> cap0 = e01 -> cap ; e01 -> flow0 = e01 -> flow ; pDst -> st_edge . cap += edge_cap ; pDst -> st_edge . cap0 = pDst -> st_edge . cap ; * tot_st_cap += edge_cap ; pDst -> st_edge . flow += edge_flow ; pDst -> st_edge . flow0 = pDst -> st_edge . flow ; * tot_st_flow += edge_flow ; pSrc -> st_edge . flow += edge_flow ; pSrc -> st_edge . flow0 = pSrc -> st_edge . flow ; * tot_st_flow += edge_flow ; return 0 ; }
Add cap and flow to an edge
Add edge flow to the source vertex st_flow
Add edge cap & flow to the destination vertex cap and flow
Add cap and flow to an edge Add edge flow to the source vertex st_flow Add edge cap & flow to the destination vertex cap and flow
/*src*/ /*dest*/ /* overflow check */ /* add flow */ /*
    pDst->st_edge.cap  += e01->cap;
    pDst->st_edge.cap0  = pDst->st_edge.cap;
    *tot_st_cap       += e01->cap;

    pDst->st_edge.flow += e01->flow;
    pDst->st_edge.flow0 = pDst->st_edge.flow;
    *tot_st_flow      += e01->flow;

    pSrc->st_edge.flow += e01->flow;
    pSrc->st_edge.flow0 = pSrc->st_edge.flow;
    *tot_st_flow      += e01->flow;
*/