source: app/src/dgp/mgraph.cc @ d33e555

help
Last change on this file since d33e555 was 28e9ae0, checked in by obrebski <obrebski@…>, 17 years ago

dgp korzysta z normalnego common.cc i bierze wspolne parametry z cmdline_common.ggo

git-svn-id: svn://atos.wmid.amu.edu.pl/utt@35 e293616e-ec6a-49c2-aa92-f4a8b91c5d16

  • Property mode set to 100644
File size: 901 bytes
Line 
1
2#include "mgraph.hh"
3#include "thesymbols.hh"
4#include "const.hh"
5
6#include <stdio.h>
7
8int MGraph::add_node(char* seg)
9{
10  nodes[n].clear();
11 
12  char field1[80], field3[80], descr[256], gph[256];
13  char* cat;
14 
15  getfield(seg,"1",field1);
16  nodes[n].pos=atoi(field1);
17
18  getfield(seg,"3",field3);
19  if(!getfield(seg,"lem",descr)) strcpy(descr,"?,?");
20
21  cat=descr;
22  while(*cat!=',' && *cat ) ++cat;
23  if(*cat) ++cat;
24 
25  Cat::add(cat);
26  nodes[n].cat=cat;
27 
28  nodes[n].pred.clear();
29 
30  char* tok;
31  int previd;
32 
33  if(!getfield(seg,"gph",gph))
34  {
35    fprintf(stderr,"No gph field. Aborting (sorry).\n");
36    exit(1);
37  }
38
39  char* ids=strtok(gph,":");
40  if(n!=atoi(ids)){fprintf(stderr,"Invalid node id in line ?. Program aborted.\n"); exit(1); }
41 
42  char *preds;
43  while(preds=strtok(NULL,","))
44  {
45    previd=atoi(preds);
46    nodes[n].pred.push_back(&nodes[previd]);
47  }
48
49  return n++;
50}
51
Note: See TracBrowser for help on using the repository browser.