1 #ifndef __ZGEN_TYPES_DEPENDENCY_TREE_H__
2 #define __ZGEN_TYPES_DEPENDENCY_TREE_H__
41 bool arc(
int source,
int target);
88 void add_edge(
int u,
int v);
97 int lvl0(
int i)
const;
100 int lvl1(
int i)
const;
103 int lvl2(
int i)
const;
109 void color(
int now,
int _0,
int _1,
int _2);
123 int root(
int i)
const;
126 int depth(
int i)
const;
129 int lca(
int u,
int v)
const;
143 void rootize(
int now,
int root,
int depth);
153 #endif // end for __SR_DEPENDENCY_H__
DependencyTree()
Definition: tree.cc:5
int set_ref(const dependency_t *ref)
Definition: tree.cc:225
bool arc(int source, int target)
Return if there is an edge between source and target.
Definition: tree.cc:70
virtual void reset(int N=kMaxNumberOfWords)
Definition: tree.cc:75
~DependencyTree()
Definition: tree.cc:8
int depth(int i) const
Definition: tree.cc:280
std::vector< int > edgeset_t
Definition: tree.h:11
const dependency_t * ref
The reference to the dependency parse instance.
Definition: tree.h:59
int lca(int u, int v) const
Definition: tree.cc:285
int lvl2(int i) const
Definition: tree.cc:220
const int kMaxNumberOfWords
Definition: settings.h:8
virtual int set_ref(const dependency_t *_ref)
Definition: tree.cc:32
int head(int i)
Access the head of node i.
Definition: tree.cc:65
edgeset_t children_[kMaxNumberOfWords]
Record the children for each node.
Definition: tree.h:62
const edgeset_t & siblings(int i)
Access the siblings of node i.
Definition: tree.cc:55
Definition: instance.h:18
int set_ref(const dependency_t *ref)
Definition: tree.cc:187
void reset(int N=kMaxNumberOfWords)
Definition: tree.cc:178
bool is_root(int i) const
Definition: tree.cc:293
int lvl1(int i) const
Definition: tree.cc:215
edgeset_t siblings_[kMaxNumberOfWords]
Record the siblings for each node.
Definition: tree.h:74
edgeset_t descendants_[kMaxNumberOfWords]
Record the descendant for each node.
Definition: tree.h:71
void reset(int N=kMaxNumberOfWords)
Definition: tree.cc:256
void go(int now)
Definition: tree.cc:109
bool same_ancestor(int u, int v) const
Definition: tree.cc:298
const edgeset_t & descendants(int i)
Access the descendants of node i.
Definition: tree.cc:50
friend std::ostream & operator<<(std::ostream &ofs, const DependencyForest &tree)
Definition: tree.cc:302
void dependency_to_tree(const dependency_t *parse)
Convert the dependency parse into the dependency tree.
Definition: tree.cc:17
int root(int i) const
Definition: tree.cc:275
friend std::ostream & operator<<(std::ostream &ofs, const DependencyTree &tree)
Definition: tree.cc:150
int indgr_[kMaxNumberOfWords]
Record the in degree of the graph.
Definition: tree.h:68
int lvl0(int i) const
Definition: tree.cc:210
const edgeset_t & children(int i)
Access the children of node i.
Definition: tree.cc:60
int parent_[kMaxNumberOfWords]
Record the parent for each node.
Definition: tree.h:65