diff options
author | Chris Dyer <redpony@gmail.com> | 2009-12-26 12:49:06 -0600 |
---|---|---|
committer | Chris Dyer <redpony@gmail.com> | 2009-12-26 12:49:06 -0600 |
commit | 3f01c8ed777aec011181dc515d9d28aa81e8530b (patch) | |
tree | 93d9f6bfb9c26cb8334ca97b42b42a27dc1dc323 /decoder/hg.h | |
parent | 9be811a26da86b87bac8696f155188d9a675e61b (diff) |
increase intersection speed by a couple orders of magnitude for linear chain graphs
Diffstat (limited to 'decoder/hg.h')
-rw-r--r-- | decoder/hg.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/decoder/hg.h b/decoder/hg.h index 7a2658b8..af8d38d2 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -14,7 +14,7 @@ // - edges have 1 head, 0..n tails class Hypergraph { public: - Hypergraph() {} + Hypergraph() : is_linear_chain_(false) {} // SmallVector is a fast, small vector<int> implementation for sizes <= 2 typedef SmallVector TailNodeVector; @@ -57,6 +57,7 @@ class Hypergraph { void swap(Hypergraph& other) { other.nodes_.swap(nodes_); + std::swap(is_linear_chain_, other.is_linear_chain_); other.edges_.swap(edges_); } @@ -175,6 +176,11 @@ class Hypergraph { inline size_t NumberOfNodes() const { return nodes_.size(); } inline bool empty() const { return nodes_.empty(); } + // linear chains can be represented in a number of ways in a hypergraph, + // we define them to consist only of lexical translations and monotonic rules + inline bool IsLinearChain() const { return is_linear_chain_; } + bool is_linear_chain_; + // nodes_ is sorted in topological order std::vector<Node> nodes_; // edges_ is not guaranteed to be in any particular order |