#include "d:\scilab-4.0\routines\stack-c.h"
void tran __PARAMS((int *a, int m, int n, int *b, int *c,int *d));

int inttran(fname) 
char *fname;
{
    static int l1, m1, n1, l2, m2, n2, l3,l4,l5;
    static int minlhs=0, maxlhs=1, minrhs=3, maxrhs=3;   //why the minlhs must equal zero??
    static int tmp1,tmp2,tmp3;
    static int m3,n3,m4,n4;

    CheckRhs(minrhs,maxrhs) ;
    CheckLhs(minlhs,maxlhs) ;
    // m2=1;
    GetRhsVar(1, "i", &m1, &n1, &l1);   //the following sentence must be wrote together!!!! 
    GetRhsVar(2, "i", &m1, &n1, &l2);
    GetRhsVar(3, "i", &m1, &n2, &l3);
    m3=*istk(l3);
    n3=500;
    CreateVar(4, "i", &m3, &n3, &l4);  
    tran(istk(l1), m1, n1, istk(l2),istk(l3),istk(l4));
    /*  Return C (3)  */
    LhsVar(1) = 4;
    return 0;
}

#include <stdio.h>
#include <stdlib.h>


#define D(i,k) d[i+(*c)*k]
void tran(a,m,n,b,c,d)  //n: edge number *c: the node number
int a[],b[],c[],d[];
int m,n;
{
    int i,j;
    int e;
    e=0;
    for (i=0;i<(*c);i++)
        for (j=0;j<500;j++)
            D(i,j)=0;
    //	g[i][0]=0;
    while (e<n) {
        i=a[e]-1;
        j=b[e]-1;
        D(i,0)++;
        D(i,D(i,0))=j;
        D(j,0)++;
        D(j,D(j,0))=i;
        e++;

    }

}
