#ifndef HYPERGRAPH_HH #define HYPERGRAPH_HH #include "grammar.hh" #include "semiring.hh" #include #include #include #include #include #include #include #include using namespace std; typedef double score_t; typedef double weight_t; typedef size_t id_t; namespace Hg { class Node; class Edge { public: id_t head; vector tails; score_t score; vector f; unsigned int mark; //Grammar::Rule rule; FIXME unsigned int arity_; unsigned int arity(); bool is_marked(); string s(); MSGPACK_DEFINE(head, tails, score, f, mark, arity_); }; class Node { public: unsigned int id; string symbol; unsigned int left; unsigned int right; score_t score; vector outgoing; vector incoming; string s(); MSGPACK_DEFINE(id, symbol, left, right, score, outgoing, incoming); }; class Hypergraph { public: vector nodes; vector edges; unsigned int arity_; unsigned int arity(); void reset(); string s(); string json_s(); MSGPACK_DEFINE(nodes, edges, arity_, nodes_by_id); }; vector topological_sort(vector& nodes); void viterbi(vector& nodes, map nodes_by_id, Node* root); } // namespace #endif