From 3f01c8ed777aec011181dc515d9d28aa81e8530b Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sat, 26 Dec 2009 12:49:06 -0600 Subject: increase intersection speed by a couple orders of magnitude for linear chain graphs --- decoder/hg.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'decoder/hg.h') 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 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 nodes_; // edges_ is not guaranteed to be in any particular order -- cgit v1.2.3