source: app/src/dgp/sgraph.hh @ a26cf42

Last change on this file since a26cf42 was 2f8d6d8, checked in by to <to@…>, 15 years ago

Poprawki kodu w C++ (nazwy plikow naglowkowych, using ...).

modified: compiledic/aut2fsa.cc
modified: dgp/grammar.hh
modified: dgp/mgraph.hh
modified: dgp/sgraph.hh
modified: dgp/thesymbols.hh
modified: gue/guess.cc
modified: kor/corlist.cc
modified: lem/lem.cc
modified: lib/symtab.cc
modified: lib/tft.h
modified: lib/tfti.h
modified: lib/ttrans.h
modified: lib/word.cc
modified: lib/word.h

  • Property mode set to 100644
File size: 1.9 KB
Line 
1#ifndef _SGRAPH_HH
2#define _SGRAPH_HH
3
4#include <stdio.h>
5
6#include <list>
7#include <vector>
8#include <bitset>
9
10#include "const.hh"
11#include "thesymbols.hh"
12
13
14using namespace std;
15
16class MNode;
17
18
19struct Arc
20{
21  int dst;
22  Role role;
23  int anc;
24 
25  Arc(int d, Role r, int a) : dst(d), role(r), anc(a) {};
26 };
27
28
29struct NodeProp
30{
31  bitset<MAXTYPES> required;
32  bitset<MAXTYPES> forbidden;
33
34  bool operator==(const NodeProp& p)
35  { return required==p.required && forbidden==p.forbidden; }
36
37  void clear()
38  { required.reset(), forbidden.reset(); }
39
40};
41
42
43struct SNode
44{
45 
46  MNode* mnode;
47
48  NodeProp prop;
49
50  bitset<MAXNODES> LV;
51  bitset<MAXNODES> LH;
52  bitset<MAXNODES> LD;
53  bool in_LH;
54
55  vector<Arc> heads;
56  vector<Arc> deps;
57
58  void clear()      { prop.clear(), LV.reset(), LD.reset(), LH.reset(), heads.clear(), deps.clear(); }
59  bool saturated()  { return prop.required.none(); }
60};
61
62
63
64class SGraph
65{
66public:
67
68  SNode nodes[MAXNODES];
69  int n; // number of nodes
70
71  enum Output { HEADS=1, DEPS=2, SETS=4, CONSTRAINTS=8 };
72
73  SGraph() : n(0) {}
74
75  void clear() { n=0; }
76 
77  int add_base_snode(MNode* mn);
78  int clone(int ancind, NodeProp newprop);
79  void update_left(int headind, int depind);
80  void update_right(int headind, int depind);
81
82  bool visible(int left, int right);
83  bool saturated(int node);
84
85  //--------------------------------------------------------------------
86
87  void read(FILE* f);
88  void write(FILE* f, list<int> nodelist, unsigned int info);
89
90  int sprint_node(char* buf, int n, unsigned int info);
91  int print_node(FILE* f, int n, unsigned int info);
92  int sprint_node_debug(char* buf, const char* pref, int n);
93  int print_node_debug(FILE* f, const char* pref, int n);
94
95  void print_arc(FILE* f, int left, int right, Role role, int dir); // 0 - left, 1 - right
96
97};
98
99
100inline bool SGraph::visible(int left, int right)
101{
102  return nodes[right].LV[left];
103}
104
105inline bool SGraph::saturated(int node)
106{
107  return nodes[node].saturated();
108}
109
110#endif
Note: See TracBrowser for help on using the repository browser.