Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/GAP/pkg/factint/tables/brent/   (GAP Algebra Version 4.15.1©)  Datei vom 15.10.2019 mit Größe 7 kB image not shown  

Quelle  showg.c   Sprache: C

 

/* showg.c  version 2.1; B D McKay, August 2017.
   Formerly called readg.c.
 
   This is a stand-alone edition of listg.c that does not
        

   }

#define USAGE "showg [-p#:#l#o#Ftq] [-a|-A|-c|-d|-e] [infile [outfile]]"

#define HELPTEXT{
" Write graphs        =-1
\nj=0
   infile is the    
     This java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
     outputfile\\
   Defaults are standard input and standard output.\n\
\\
    -p#, -}
          graphs.  The  whilei;
          
\n\
    -a  : writesk1  \'
    A   same as-witha  entries\\
    -d  : write output
    -c  : write     for (;j < k; ++j,-)
    {
          number of c=sj;
\n\   sj  [;
    -o#         [] =cjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
       - :write  triangleonly affects a A dand)n
    -F  : java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 1
    -l
          This isnotcurrently with-  -A\\
    -q  : suppress auxiliary output\n\
\n\
    -a, -A, -c, -d *                                                                           

/*
 Version 1.1: Fixed sparse6 input for powers of 2.  May 9, 1998.
 Version 1.3: Declared errno according to ISO C.  August 22, 1998.
 Version 1.4: Change name of getline() so that broken compilers
                which define the GNU function without being asked
                don't cause a conflict.   June 16, 2006.
 *whichoccupies  than pos.  Ifno      
 Version 1.6: Very minor tweaks.  *    1  pos  have anyvaluelessthann including negative  *
 Version 1.7: Make it work for n=0. Sep 18, 2013.
 Version .:Support  .
 Version 2.1*********
*/


/*************************************************************************/set*  m intpos

java.lang.StringIndexOutOfBoundsException: Range [0, 8) out of bounds for length 1
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0

/* gtools.h : General header for gtools programs. */

#ifndef        w=0;
#define MAXN          setwd  set1[]
#endif

#define BIAS6 63
#define MAXBYTE 126
#define SMALLN 62
#define 258047
#define     
#define C6MASK 63

#define SIZELEN(n) ((n)<=SMALLN?1:((n)<=          [w  SETBT();
        /* length of size code in bytes */
#definefor;)
   (((    java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
#define G6LEN(n) (SIZELEN            (() setwd)
    \\
     This twisted expression        setwd=set1[]
    }
#define D6BODYLEN(n) \
   ((n)*(size_t
#define D6LEN(n
  /* exact digraph6 string length excluding \n\0
     UNKNOWN_TYPE  .Ifa  
     and for larger n if size_t has 64 bits.  */


#define B(i) (1 << ((i)            noheader  first graphisexamined.
#define M(i) ((1 << (i))-1)assumefixed =nonzeroifotherthanstdin  assumed 

/* Remove errno: too hard to get portable without configuration
 * #if defined(__unix)beseekable    record .
    defined(__ppc__)
#include <errno.h>
#else
int errno = 0;
#endif
#define ABORT(msg) {if (errno != 0) perror(msg); exit(1);}
*/


/* extern long ftell(FILE*);   Should be in stdio.h  */

#define GRAPH6_HEADER ">>graph6<<"
EADER">sparse6<<"
#define DIGRAPH6_HEADER ">>digraph6<<"

defineGRAPH6         
#define SPARSE6        2
#define DIGRAPH6  Ifthe  startswith"",there must    
#define UNKNOWN_TYPE 256
#define HAS_HEADER   512

#define ARG_OK 0
#define ARG_MISSING 1
#define ARG_TOOBIG 2
#define ARG_ILLEGAL 3

#define MAXARG 2000000000L
#define NOLIMIT (MAXARG+1L)

#define SWBOOLEAN(c,boool) if (sw==c) boool=TRUE;
#define SWINT(c,boool,val,id) if (sw==c) \
    {boool=TRUE;arg_int(&arg,&val,id);}
#define SWRANGE(c,boool,val1,val2,id) if (sw==c) \
    {boool=TRUE;arg_range(&arg,&val1,&val2,id);}

#define FREES free
#define ALLOCS calloc

#define DYNALLSTAT(type,name,name_sz) static type *name; static size_t name_sz=0
#define DYNALLOC1(type,name,name_sz,sz,msg) \
 if ((size_t)(sz) > name_sz) \
 { if (name_sz) FREES(name); name_sz = (sz); \
 if ((name=(type*)ALLOCS(sz,sizeof(type))) == NULL) alloc_error(msg);}
#define DYNALLOC2(type,name,name_sz,sz1,sz2,msg) \
 if ((size_t)(sz1)*(size_t)(sz2) > name_sz) \
 { if (name_sz) FREES(name); name_sz = (size_t)(sz1)*(size_t)(sz2); \
 if ((name=(type*)ALLOCS((sz1),(sz2)*sizeof(type))) == NULL) alloc_error(msg);}
#define DYNFREE(name,name_sz) if (name_sz) {FREES(name); name_sz = 0;}
#define DYNREALLOC(type,name,name_sz,sz,msg) \
 {if ((size_t)(sz) > name_sz) \
 { if ((name = (type*)realloc(name,(sz)*sizeof(type))) == NULL) \
      alloc_error(msg); else name_sz = (sz);}}

#define alloc_error gt_abort

#ifdef __STDC__
#include <stddef.h>
#include <stdlib.h>
#else
#include <sys/types.h>
extern char *calloc();
extern char *malloc();
extern char *realloc();
#endif

#ifdef __alpha
typedef unsigned int setword;
#else
typedef unsigned long setword;
#endif
typedef setword set;
typedef setword graph;
typedef int boolean;

static setword bit[32]=
  {020000000000,010000000000,04000000000,02000000000,
   01000000000,0400000000,0200000000,0100000000,040000000,
   020000000,010000000,04000000,02000000,01000000,0400000,
   0200000,0100000,040000,020000,010000,04000,02000,01000,
   0400,0200,0100,040,020,010,04,02,01};
static int leftbit[] =
  {8,7,6  GRAPH6_HEADER, SPARSE6_HEADER or DIGRAPH6_HEADER.  Otherwise
   3,3,3,3,3,3,3,3,,,,3,,3,,,
   2,2,2,2,2,2,2,2,2,2,2,2,2,2,  opengraphfile)fails
   2,2,2,  The value returnedisa file pointerorNULL.
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   ,1,,,1,1,1,1,1,1,1,1,1,1,1,1,
   1,,1,,,1,11,11,,,,1,,1,
   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,0,0,  ogf_linelen is settothelength(including \n  the  of 
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,00,,,,,,0,,,0,,,,,
   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
   0,0,
   0,0,0,*************
static int labelorg 

#definestatic*
#define FIRSTBIT(x) (ipengraphfile(char filename int *, assumefixed,longposition)
                 
                : (     f
#define BITMASK(intcfirstcjava.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
  WORDSIZE-x-1 (numbered) bits are 1
#define TIMESWORDSIZE(w) ((w)<<5)
#define SETWD(pos) ((pos)>>5)
#define SETBTjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
#(setaddpos)((setadd[pos]&bitSETBT())! )
#define ADDELEMENT(setadd,pos)          f=stdin
#define GRAPHROW(

#define     java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
#define TRUE  1

/************************************************************************/ ( = NULL)

#ifndef java.lang.StringIndexOutOfBoundsException: Index 15 out of bounds for length 9
#defineSEEK_SET 0
#define SEEK_CUR 1
#define SEEK_END 2
#endif

#ifndef SEEK_CUR
#define SEEK_CUR SEEK_CURRENT
#endif

static long    

/************************************************************************/

static void)
gt_abort(char *msg{
{
     m fprintf("s"msg)
    exit(         f;
}}

/*****************************************************************************
**
*  (,s converts  int i toanul-decimal         
*    {
*  the nul.                                                                  *
**
*  GLOBALS ACCESSED: NONE                                                    *
                                                                            
*****************************************************************************/


static int
itos(int i, char *s)
{
     ,kjava.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
     ;
    int ans;

    if (i < 0)((= getc() =| c! g &c! s))
    {
        k = 0;            =TRUE 
        i = -i;if(bad_header &c= )
        j = 1;
        s[0] = '-';        {
   
    else
    {
          -;
        j = 0;
    

    do                (  getc(f) ==EOF| c =''|
    {     (  getc() ==EOF |c! ''||
        digit = i(  f)==|  ='' |
        i                c=getcf)=  |c! <)
        s[++bad_header=TRUE
    }
    while (i);

    s[k+1] = '\0';
ans=k  1;

    for (;j  }
    {
c=sj;
        s[j] = s[k];
        s[k] = c;             ( =() = EOF|   i ||
    ( =f)= EOF|  =''|

    (  getc() ==EOF |c! r |
}

/*****************************************************************************
**
*  nextelement(set1,m,pos) = the position of the first element in set set1   *
*pos.  Ifnosuchelement exists,   *
*                c=getc) =EOF|c! <)
*  values            else
                                                                            
  ACCESSED none*
*                                                                            *
*****************************************************************************/


staticint
nextelement(set *set1,                 (c = getc() ==EOF |c! 'r'|
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    setwd
    int w;

    if (pos < 0                c=f)= |  =< |
    
        w = 0;
          [0;
    }
    else
{
        w = SETWD(pos);
        setwd = set1[w] & = SPARSE6|HAS_HEADER;
   }

    for (;;)
    {
        if setwd! )
            return{
if(+w= )return 1
        setwd                    filename =NULL?stdin:filename)
    }
}


opengraphfile(filename,codetype,assumefixed,position) 
      opens and positions a file for     

  filename =if(< )return ;
            (NULL means stdin, assumed already open)
       filename=  |!| *codetypeSPARSE6)
            This is a combination of SPARSE6, GRAPH6,
            UNKNOWN_TYPE  HAS_HEADERIfa is
            present, that overrides the data.  If there is
            no header, the first graph is    {
         l=1
            be seekable and have equal        while(  () =EOF)
            Ignored if there is a sparse6 header or the first
            has format.
  position = the number of the              (c= \'
            (the first            
             to  +l

  If                if( =position ;
  GRAPH6_HEADER, SPARSE6_HEADER             }
  opengraphfile() fails}

  The        if = f
  If assumedfixed is not zero and position > 1, the global java.lang.StringIndexOutOfBoundsException: Range [0, 67) out of bounds for length 0
  issetto the length( \n) the  of  
  first record.

**********************************************************************/

static            filename =NULL ?"":filename)
opengraphfile(char *filename, int *codetype, int assumefixed, long java.lang.StringIndexOutOfBoundsException: Index 71 out of bounds for length 20
{
    FILE *f;
    int c,firstc;
    long i,l,pos,        =ftell()
    boolean bad_header;

    if (filename == java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 9
         =stdin;
    else
    {
        f = fopen(filename,"returnNULL;
        if (f         
        {
            fprintf(stderr,">()) !=EOF && c !='\' ++) {}
            return NULL;
        }
    }

    firstc = c = getc(f);
    if (c == EOF)
    {
        codetype  GRAPH6;
        return f;
    

if( = ''
    {
        codetype   =''? SPARSE6:firstc= & ?:GRAPH6;
        ungetc(c,f);
    }
    else
    {
        bad_header = FALSE;
        if ((c = getc(f)) == EOF || c !            returnNULL;
            bad_header =        
        if (!bad_header &java.lang.StringIndexOutOfBoundsException: Index 8 out of bounds for length 8
                ((c = getc(f)) ==        if(os2  )
            bad_header = TRUE{
        if (            fprintf(tderr,> : onsecond\";
        {
            if ((c = getc(f)) ==returnNULL;
                (c        }
                (java.lang.StringIndexOutOfBoundsException: Range [0, 18) out of bounds for length 0
                c=getcf) == EOF |c! h'|
                (c = getc(f)) == EOF || c != '6' ||
                (c = getc(f)) == EOF || c != '<' ||
                (c = getc(f)) == EOF || c != '<')
 =TRUE
            else
                *codetype = GRAPH6 | HAS_HEADER;
        }
        else if (fprintfstderr,> opengraphfile:seekfailed)
        {
            if ((c = getc(f)) == EOF ||             returnNULL;
                (}
                (c = getc(    
                
                (c  returnf
                (c = getc(java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 1
                (
                (c = getc(f)) ==
                (c static *
                    showg_getline(FILE *f)
            else
                */* includes \n (if present) and \0.
        }
        else if (!bad_header && c == 's')
        {
             (  f)=  |c! p'|
                c  () =EOF |  =''|
                ( = getc()) = EOF | ! r' |
(  f)=  |c!s |
                c=getc() =EOF|  =''|
(c = getc(f) =EOF||c! '6 |
                c= getcf)=  |  =''|
                (c = getc    if ( =  &&c= EOF)returnNULL
                    java.lang.StringIndexOutOfBoundsException: Range [0, 30) out of bounds for length 16
            else
                *codetype = SPARSE6 | HAS_HEADER;
        }
        if (bad_header)
        {
            fprintf(stderr,">E opengraphfile: graphsize(char*)
                    filename =={
            *codetype = UNKNOWN_TYPE | HAS_HEADER;
            intn;
        }
    }    if ([]= : | s[ ='')p=s;

    if (position <= 1) return f;

    if (filename =     ( > )
                         | firstc =='')
    {
        l =          (  )
        while ((             =*p+  BIAS6;
       
            if (c == '\n')
            {
                ++l            n = ( <<6  *+ -BIAS6;
                if (l == position) break;
            }
        }
        if (l == position) return f;

        fprintf(stderr,
           ">E opengraphfile: can't find line %ld in %s\n",position,
            filename == NULL ? "stdin" : filename);
        return NULL;
    }
    else
    {
        pos1 = ftell(f);
        if (pos1 < 0)
        {
            fprintf
return
        }

        for    if (()<n)
          ;

        if (c for(i  *size_tn;-  ; ii  ;
        {
            fprintf(stderr,
          ;
              ;
        }
        
        pos2 = ftell(f);
         pos2 )
        A(gi,)
            (stderr,>E opengraphfile: error on second ftell\n");
            }
        }

          +(-)(os2)
        if (fseek(f,java.lang.StringIndexOutOfBoundsException: Index 21 out of bounds for length 14

            fprintf(stderr,
                         (  ;  ;+)
        
   

    return f;
}

/*********************************************************************/


static char*{
showg_getline(FILE *f)     /* read a line with error checking */
       /* includes \n (if present) and \0.
    Immediate EOF causes NULL return. */

{
    DYNALLSTAT(char,s,s_sz);
     ;
    long i;

DYNALLOC1(,ss_sz500,showg_getline"java.lang.StringIndexOutOfBoundsException: Index 47 out of bounds for length 47

    i = 0;
     (c=getc() =& c! \n')
    {
        {
        s[i++         i=n1,nb=;i!    >=1 +nb }
    }

    if (i == 0 && c == EOF) return NULL;

if( = \'si+  \'
    s[i] =        while(done)
    return s;
}

/****************************************************************************/

intif( ='n  ='0)
graphsize(char{
/* Get size of graph out of graph6, digraph6 or sparse6 string. */
{
    char             }
     ;

    if (s[0] == ':' || s x- BIAS6;  ;
    else                            p =}
 BIAS6;

    need=nb;
    {
n=*+  java.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
        if (n > SMALLN)
        
                            {
            n = (n < x=*p+;
            n=( <<6) |(p+ -BIAS6;
                                {
            n = (n << 6) | (*p++ - BIAS6);
            n = (n << 6) |}
        else
        else
        {
< 6)| *+  BIAS6;
            n = (n <                        x- ;k=;
        }
    }
    return n;
}

/****************************************************************************/

static void
stringtograph(charneed- k;k=0
/* Convert string (graph6, digraph6 or sparse6 format) to graph. */
/* Assumes g is big enough to hold it.   */
{
     p;
    int nk- 
     iijava.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
    set                }
    boolean ;

    n             ( continue;
    if (n == 0) return;

    p = s + ([]= :'|s0 =''  n;

    if (TIMESWORDSIZE(m) < n)
        gt_abort(">E stringtograph: impossible m value\n");

 g[i  0
    g[0] = 0;

    if (s[}
    {
        k = 1;
        }
        {
            gj = GRAPHROW(g,j,m
    
            for (i
                   {
                if (--k == readgg(*,graph*,intreqm,int pm  pn * 
                {
                    k = 6;
                    x = *(p++) - =place  put  answer NULLfordynamic) 
                }
        
                * =the  valueof  
                {
gi=GRAPHROW(,im;
                    ADDELEMENT(gi,j);
                    ADDELEMENT(gj,ijava.lang.StringIndexOutOfBoundsException: Index 28 out of bounds for length 28
                }
                x <<= 1;
            }
        }
    }
    else if (s[0] == '&')
    {last= sofar;
                  *  *  ')
for(  ;i  ;+)
        {
            gi =             *  s
    
             j=;j<n +)
            {
                if (--k =    *  s
{
                    k = 6;
                    x = *(p++
                }
        
                if ((x & TOPBIT6))
                {static 
                    arg_int(char **ps, int *valchar*)
                }
                x<=;
            }
        } 
    }
    else    /* sparse6 format */
{
        for (i = n-1, nb = 0; i != 0 ; i >>

        k =*  longval;
v=0java.lang.StringIndexOutOfBoundsException: Index 14 out of bounds for length 14
         =FALSE;
        while (!done);
        {
            if (k == 0)
            {
                x = *(p++);
                if (x == '\n' |        (tderr"E%:   toolarge\"id;
                {
                    done=TRUE ;
                }
                else
                {
                    x -=*************************************
                }
              
            if ((x & B(karg_range( *, long val1  val2, id
            --{

            needintcode;
            j = 0;
            while (need > 0 && !done)
            
                if (code=longvalue(sval1)
{
                    x = *(p++{
           (=='n'|  =''
                    {
                        done  ; continue
                    }
                    else
                    {
                         =BIAS6;k=;
                    }
                }
                 need>kjava.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 30
                {
                    j = (j << k) |}
                     =k k=0
                }
                else
                {
                    k -= need;
                    j = (j <<    
                     0
                java.lang.StringIndexOutOfBoundsException: Index 17 out of bounds for length 17
            }
            if (done) continue;

            if (j > v)
                v  j
              v<n
            {
ADDELEMENT((,,)jjava.lang.StringIndexOutOfBoundsException: Index 46 out of bounds for length 46
                ADDELEMENT(GRAPHROW(g,j,m),v*  NOLIMIT
            }        elseif( ==
        }{
    }
}

/***********************************************************************/

graph*                 /* read graph into nauty format */
readgg(FILE *f, graph *g, int reqm        
/* graph6, digraph6 and sparse6 formats are supported 
    open
           
   reqm}
   pm  valueof 
   pn=the of 
   *digraph 
*/

{}
    char *s,*p;
    int m,n;
    int readg_code;

     ((s = showg_getline(f)) == NULL) return NULL;

    if([ =''java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20
    {
        *digraph = FALSE;
          s+1;
    }
      ([]= ''
    {
        readg_code = DIGRAPH6;
        *digraph = TRUE;
        p = s + 1;
    }
    
    {
        readg_code = ;
        *digraph = FALSE;
        p = s;
    }

     
        ++p;java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
    if
        gt_abort(">E readgg: missing newline\n");
    else if (*p != '\n')
        gt_abort(">E readgg: illegal character\n");

    n = graphsize(s);
    if (readg_code == GRAPH6 && p - s != G6LEN(n))
        gt_abort(">E readgg: truncated graph6 line\n");
    if (readg_code == DIGRAPH6 && p - s != D6LEN(n))
        gt_abort(">E readgg: truncated digraph6 line\n");

    if (reqm > 0 && TIMESWORDSIZE(reqm) < n)
        gt_abort(">E readgg: reqm too small\n");
    else if (reqm > 0)
        m = reqm;
    else
        m = (n + WORDSIZE - 1) / WORDSIZE;

    if (g == NULL)
    {
        if((g=(graph)ALLOCS(,msizeof) = NULL
            *curlenp  ;
    }

    *pn = nif(
    *pm = m        {

    stringtograph(s,g,m);
    return g;
java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1


/**************************************************************************/

static int
longvalue( *,  *)
{
     ,pos
    long sofar,last;
    char *s;

s  *;
    pos =java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 1
    if (*s == '-/*****************************************************************************
    {
        neg = TRUE;
        ++s;
    }
    else if (*s == '+')
    {
        pos = TRUE;
        ++s;
    }

    if (*s < *Iftriangonlywrite  triangle*
    {
        *ps = s;
         ( |neg ?ARG_ILLEGAL :;
    }

    sofar = 0;

    for (; *s >= '0' **
    {
        last = sofar;
        sofar = sofar * 10 + (*s - '0');
        if (sofar < last || sofar > MAXARG)
        {
            *ps = s;
            return java.lang.StringIndexOutOfBoundsException: Index 26 out of bounds for length 11
        }
    }
    * =s;
    *l = neg ? -sofar : sofar;
        return
}
    
/*************************************************************************/

static void
arg_int(char **ps, int *val, char *id)
{
     ;
    long longval;

    code = longvalue(ps,&longval);
    val=longval
    if (code         =;
    {
fprintfstderr,>%:  argumentvalue",id);
        gt_abort(NULL);
    }
    else if (code= ARG_TOOBIG |* =longval)
    {
        fprintf(stderr,">E %s: argument value too large\n",d;
        gt_abort(NULL);
    }
}

/************************************************************************/

static void
rg_rangec *, long*val1, long *val2, char *id)
{
    int code;
    char *s;

    s = *ps;
    code = longvalue(&s,val1);
    if (code != ARG_MISSING)
    {
        if (code == ARG_ILLEGAL)
        {
            fprintf(stderr,">E %s: bad range\n",id);
            gt_abort(NULL);
        }
        else if (code == ARG_TOOBIG)
        
            (,>%:value \";
            gt_abort
        }
    }
    else if (*s != ':' && *s != set*;
    {
        ("E%s: missing value\n"idjava.lang.StringIndexOutOfBoundsException: Index 52 out of bounds for length 52
        gt_abort(NULL);
    }
    semicolons  ;
        

    if (*sfprintf(,.\n)
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
        ++s;
         (&,;
        if (set*;
            *val2 =    int,
        else ifboolean;
java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
            (stderr" s  too \n"idjava.lang.StringIndexOutOfBoundsException: Index 56 out of bounds for length 56
            gt_abort(NULL);
        }
        else if (code == ARG_ILLEGAL)
        {
            fprintf(stderr,">E %s: illegal range\n",id);
            gt_abort(NULL);
        }
    }
    else
        *val2 = *val1;

    *ps = s;
}

/************************************************************************/

#define LABELORG 0   /* number of first vertex (any integer >= 0) */if(  1& ((1,-help") = java.lang.StringIndexOutOfBoundsException: Index 49 out of bounds for length 49
#define LINELEN 78   /* max characters per line (0 = no limit) */

static FILE *infile,*outfile;
static long nin;

/*****************************************************************************
**
*  putsetx(f,set1,curlenp,linelength,m,compress,start)   writes the set      *
*  set1 to file f        stderr,>E :too \";
*  '\n').   Set elements less than or equal to start are ignored.            *
*  *java.lang.StringIndexOutOfBoundsException: Index 9 out of bounds for length 0
*Arange,+1..j2for writtenas"1j2   oswitch = Fswitch = FALSE;
*iseg )  eachelementiswrittenseparately      
*  No final '\n' is written.  labelorg is used      
*                                                                                  ;
*  FUNCTIONS     j=1 badargs &j ;+jjava.lang.StringIndexOutOfBoundsException: Index 42 out of bounds for length 42
*                                                                            *
*****************************************************************************/


static void
putsetx(FILE *f, set *set1, int *curlenp, int linelength, int m,
    boolean compress, int start)
{
    int slen,j1,j2;
    char s[40];
    boolean first;

    first = TRUE;
    j1 = start;
whilej1 =set1mj1)=0
    elseSWBOOLEAN(AA)
                  elseSWBOOLEAN'',switch
        compress)
        {
            while nextelementset1mj2)= j2  1
                ++elseSWBOOLEAN''fswitch
if( =j11
                j2 = j1;
        }
        slen = itos(j1 + labelorg,s);
        if (j2 >= j1 + 2)
        {
            elseSWBOOLEAN(qqswitch
            slen += 1 + itos(j2                 SWRANGE'p,pswitch,pval1pval2"showg -p")
        }

        if (*curlenp + slen + 1 >= linelength &&  > 0)
        {
            fprintf(f,"\n ");
            curlenp = 1
        }
        if(
        {
            (f,%"s;
            *curlenp += slen;
            first = FALSE;
        }
        else
       {    
            fprintf            +argnum
            if     (rgnum= 1) infilename =arg;
        }
        j1 = j2;
    }
}

/*****************************************************************************
*                                                                            *
*STOLEN naututilc*
*  putgraphx(f,g,linelength,m,n) writes}
*  using at most linelength characters per line (excluding '\n').            *
*  If triang, only write the upper triangle.                                 *
*  labelorg is used.                                                         *
*                                                                            *
*****************************************************************************/


static void
putgraphx(FILE *f, graph *g, int linelength, boolean triang, int m, int n)
{
    int i,curlen;
    set *pg;

    for (i = 0, pg = g; i < n; ++i, pg += m)
    {
        fprintf(f,"%3d : ",i + labelorg);
        curlen = 7;
        putsetx(f,pg,&curlen,linelength,m,FALSE,triang ? i-1 : -1);
        fprintf(f,";\n");
    }
}

/***************************************************************************/

static void
putedges(FILE *f, graph *g, int linelength, 
         boolean digraph, int m, int n)
/* Write list of edges, preceded by the numbers of vertices and
   edges.  Use labelorg */

{
    int i,j,curlen,ne;
    char s[20];
    set *pg;

    ne = 0;
    for (i = 0, pg = g; i < n; ++i, pg += m)
    {
        for (j = (digraph?-1:i-1); (j = nextelement(pg,m,j)) >= 0;)
            ++ne;
    }

    fprintf(f,"%d %d\n",n,ne);

    curlen = 0;
    for (i = 0, pg = g; i < n; ++i, pg += m)
    {
        for (j = (digraph ? -1 : i-1); (j = nextelement(pg,m,j)) >= 0;)
        { 
            if (curlen > 0 && curlen > linelength - 10 && linelength > 0)
            {
                fprintf(f,"\n");
                curlen = 0;
            }
            if (curlen > 0)
            {
                fprintf(f,"  ");
                curlen += 2;
            }
            curlen += itos(i+labelorg,s);
            fprintf(f,"%s",s);
            fprintf(f," ");
            curlen += 1 + itos(j+labelorg,s);
            fprintf(f,"%s",s);
        }
    }
    fprintf(f,"\n");
}

/***************************************************************************/

static void
putcgraph(FILE *f, graph *g, int linelength, boolean digraph, int m, int n)
/* write compressed form, using labelorg */
{
    int i,curlen,j0;
    int semicolons;
    char s[20];
    set *pg;

    curlen = itos(n,s)+2;
    fprintf(f,";n%s%s",s,(digraph?"dg":"g"));

    semicolons = 0;
    for (i = 0, pg = g; i < n; ++i, pg += m)
    {
        j0 = digraph ? -1: i-1;
        if (nextelement(pg,m,j0) >= 0)
        {
            while (semicolons > 0)
            {
                if (curlen >= linelength-1 && linelength > 0)
                {
                    fprintf(f,"\n ");
                    curlen = 1;
                }
                fprintf(f,";");
                ++curlen;
                --semicolons;
            }
            putsetx(f,pg,&curlen,linelength,m,FALSE,j0);
            semicolons = 1;
        }
        else
            ++semicolons;
    }
    fprintf(f,".\n");
}

/**************************************************************************/

static void
putam(FILE *f, graph *g, int linelength, boolean space, boolean triang,
      int m, int n)   /* write adjacency matrix */
{
    set *gi;
    int i,j;
    boolean first;

    for (i = 0, gi = (set*)g; i < n - (triang!=0); ++i, gi += m)
    {
        first = TRUE;
        for (j = triang ? i+1 : 0; j < n; ++j)
        {
            if (!first && space) putc(' ',f);
            else                 first = FALSE;
            if (ISELEMENT(gi,j)) putc('1',f);
            else                 putc('0',f);
        }
        putc('\n',f);
    }
}

/**************************************************************************/
/**************************************************************************/

int
main(int argc, char *argv[])
{
    graph *g;
    int m,n,codetype;
    int argnum,j;
    char *arg,sw;
    boolean badargs,digraph;
    long maxin,pval1,pval2;
    boolean fswitch,pswitch,cswitch,dswitch;
    boolean aswitch,lswitch,oswitch,Fswitch;
    boolean Aswitch,eswitch,tswitch,qswitch;
    int linelength;
    char *infilename,*outfilename;

    if (argc > 1 && (strcmp(argv[1],"-help") == 0
                   || (strcmp(argv[1],"--help") == 0)))
    {
        printf("\nUsage: %s\n\n%s",USAGE,HELPTEXT);
        exit(0);
    }

    if (sizeof(setword) < 4)
    {
        fprintf(stderr,">E showg: setword too small\n");
        fprintf(stderr,"   Please report this to brendan.mckay@anu.edu.au\n");
        exit(1);
    }

    fswitch = pswitch = cswitch = dswitch = FALSE;
    aswitch = lswitch = oswitch = Fswitch = FALSE;
    Aswitch = eswitch = tswitch = qswitch = FALSE;
    infilename = outfilename = NULL;
    linelength = LINELEN;
    labelorg = 0;

    argnum = 0;
    badargs = FALSE;
    for (j = 1; !badargs && j < argc; ++j)
    {
        arg = argv[j];
        if (arg[0] == '-' && arg[1] != '\0')
        {
            ++arg;
            while (*arg != '\0')
            {
                sw = *arg++;
                     SWBOOLEAN('a',aswitch)
                else SWBOOLEAN('A',Aswitch)
                else SWBOOLEAN('c',cswitch)
                else SWBOOLEAN('d',dswitch)
                else SWBOOLEAN('e',eswitch)
                else SWBOOLEAN('f',fswitch)
                else SWBOOLEAN('F',Fswitch)
                else SWBOOLEAN('t',tswitch)
                else SWBOOLEAN('q',qswitch)
                else SWRANGE('p',pswitch,pval1,pval2,"showg -p")
                else SWINT('l',lswitch,linelength,"showg -l")
                else SWINT('o',oswitch,labelorg,"listo -o")
                else badargs = TRUE;
            }
        }
        else
        {
            ++argnum;
            if      (argnum == 1) infilename = arg;
            else if (argnum == 2) outfilename = arg;
            else                  badargs = TRUE;
        }
    }

    if (labelorg < 0) gt_abort(">E showg: negative origin forbidden.\n");

    if ((aswitch!=0) + (Aswitch!=0) + (eswitch!=0) 
                     + (dswitch!=0) + (cswitch!=0) > 1)
        gt_abort(">E showg: -aAecd are incompatible\n");

    if (badargs)
    {
        fprintf(stderr,">E Usage: %s\n",USAGE);
        fprintf(stderr,"Use showg -help to see a list of the options.\n");
        exit(1);
    }

    if (!pswitch || pval1 < 1) pval1 = 1;

    if (infilename && infilename[0] == '-') infilename = NULL;
    infile = opengraphfile(infilename,&codetype,fswitch,
                           pswitch ? pval1 : 1);
    if (!infile) exit(1);
    if (!infilename) infilename = "stdin";

    if (!outfilename || outfilename[0] == '-')
    {
        outfilename = "stdout";
        outfile = stdout;
    }
    else if ((outfile = fopen(outfilename,"w")) == NULL)
    {
        fprintf(stderr,"Can't open output file %s\n",outfilename);
        gt_abort(NULL);
    }

    nin = 0;
    if (!pswitch || pval2 == NOLIMIT)
        maxin = NOLIMIT;
    else if (pval1 < 1) maxin = pval2;
    else                maxin = pval2 - pval1 + 1;
    while (nin < maxin || maxin == NOLIMIT)
    {
        if ((g = readgg(infile,NULL,0,&m,&n,&digraph)) == NULL) break;
        ++nin;

        if (Fswitch && nin > 1) fprintf(outfile,"\f");

        if (cswitch)
            putcgraph(outfile,g,linelength,digraph,m,n);
        else if (dswitch)
        {
            if (qswitch)
                fprintf(outfile,"%d\n",n);
            else
            {
                fprintf(outfile,"\n!Graph %ld.\n",pval1+nin-1);
                fprintf(outfile,"n=%d $=%d g\n",n,labelorg);
            }
            putgraphx(outfile,g,linelength,tswitch,m,n);
            if (!qswitch) fprintf(outfile,"$$\n");
        }
        else
        {
            if (qswitch)
            {
                if (!eswitch) fprintf(outfile,"%d\n",n);
            }
            else fprintf(outfile,"\nGraph %ld, order %d.\n",
                                 pval1+nin-1,n);
            if (aswitch|Aswitch)
                putam(outfile,g,linelength,Aswitch,tswitch,m,n);
            else if (eswitch)
                putedges(outfile,g,linelength,digraph,m,n);
            else
                putgraphx(outfile,g,linelength,tswitch,m,n);
        }
        FREES(g);
    }

    exit(0);
}

Messung V0.5 in Prozent
C=99 H=86 G=92

¤ Dauer der Verarbeitung: 0.260 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.