causal_graph.h
Go to the documentation of this file.
00001 #ifndef CAUSAL_GRAPH_H
00002 #define CAUSAL_GRAPH_H
00003 
00004 #include <iosfwd>
00005 #include <vector>
00006 #include <map>
00007 using namespace std;
00008 
00009 class Operator;
00010 class Axiom_relational;
00011 class Axiom_functional;
00012 class Variable;
00013 
00014 class CausalGraph
00015 {
00016     private:
00017         const vector<Variable *> &variables;
00018         const vector<Operator> &operators;
00019         const vector<Axiom_relational> &axioms_rel;
00020         const vector<Axiom_functional> &axioms_func;
00021         const vector<pair<Variable *, int> > &goals;
00022 
00023         typedef map<Variable *, int> WeightedSuccessors;
00024         typedef map<Variable *, WeightedSuccessors> WeightedGraph;
00025         WeightedGraph weighted_graph;
00026         typedef map<Variable *, int> Predecessors;
00027         typedef map<Variable *, Predecessors> PredecessorGraph;
00028         // predecessor_graph is weighted_graph with edges turned around
00029         PredecessorGraph predecessor_graph;
00030 
00031         typedef vector<vector<Variable *> > Partition;
00032         typedef vector<Variable *> Ordering;
00033         Ordering ordering;
00034         bool acyclic;
00035 
00036         void weigh_graph_from_ops(const vector<Variable *> &variables,
00037                 const vector<Operator> &operators,
00038                 const vector<pair<Variable *, int> > &goals);
00039         void weigh_graph_from_axioms_rel(const vector<Variable *> &variables,
00040                 const vector<Axiom_relational> &axioms_rel,
00041                 const vector<pair<Variable *, int> > &goals);
00042         void weigh_graph_from_axioms_func(const vector<Variable *> &variables,
00043                 const vector<Axiom_functional> &axioms_func,
00044                 const vector<pair<Variable *, int> > &goals);
00045         void get_strongly_connected_components(Partition &sccs);
00046         void calculate_topological_pseudo_sort(const Partition &sccs);
00047         void calculate_pseudo_sort();
00048         void calculate_important_vars();
00049         void dfs(Variable *from);
00050         void count(Variable *curr_source, Variable *curr_target);
00051     public:
00052         CausalGraph(const vector<Variable *> &variables,
00053                 const vector<Operator> &operators,
00054                 const vector<Axiom_relational> &axioms_rel,
00055                 const vector<Axiom_functional> &axioms_func,
00056                 const vector<pair<Variable *, int> > &the_goals);
00057         ~CausalGraph() {
00058         }
00059         const vector<Variable *> &get_variable_ordering() const;
00060         bool is_acyclic() const;
00061         void dump() const;
00062         void generate_cpp_input(ostream &outfile,
00063                 const vector<Variable *> & ordered_vars) const;
00064 };
00065 
00066 extern bool g_do_not_prune_variables;
00067 
00068 #endif


tfd_modules
Author(s): Maintained by Christian Dornhege (see AUTHORS file).
autogenerated on Mon Oct 6 2014 07:52:06