31#include <boost/graph/adjacency_list.hpp>
32#include <boost/graph/directed_graph.hpp>
33#include <boost/graph/graph_traits.hpp>
34#include <ql/shared_ptr.hpp>
36#include <boost/graph/depth_first_search.hpp>
37#include <boost/graph/tiernan_all_cycles.hpp>
47template <
class OutputStream>
struct CyclePrinter {
48 CyclePrinter(OutputStream& os) :
os_(os) {}
49 template <
typename Path,
typename Graph>
void cycle(
const Path& p,
const Graph& g) {
50 typename Path::const_iterator i, end = p.end();
51 for (i = p.begin(); i != end; ++i) {
60template <
typename Graph>
string getCycles(
const Graph& g) {
61 std::ostringstream cycles;
62 CyclePrinter<std::ostringstream> cyclePrinter(cycles);
63 boost::tiernan_all_cycles(g, cyclePrinter);
68template <
typename Vertex>
struct DfsVisitor :
public boost::default_dfs_visitor {
69 DfsVisitor(std::vector<Vertex>& order,
bool& foundCycle) :
order_(order),
foundCycle_(foundCycle) {}
70 template <
typename Graph>
void finish_vertex(Vertex u,
const Graph& g) {
order_.push_back(u); }
71 template <
typename Edge,
typename Graph>
void back_edge(Edge e,
const Graph& g) {
foundCycle_ =
true; }
85 const QuantLib::ext::shared_ptr<TodaysMarketParameters>& params,
87 const QuantLib::ext::shared_ptr<const CurveConfigurations>&
curveConfigs,
103 using Graph = boost::directed_graph<Node>;
104 using IndexMap = boost::property_map<Graph, boost::vertex_index_t>::type;
105 using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
110 void buildDependencyGraph(
const std::string& configuration, std::map<std::string, std::string>& buildErrors);
115 friend std::ostream&
operator<<(std::ostream& o,
const Node& n);
121 const QuantLib::ext::shared_ptr<TodaysMarketParameters>
params_;
std::map< std::string, Graph > dependencies()
void buildDependencyGraph(const std::string &configuration, std::map< std::string, std::string > &buildErrors)
boost::graph_traits< Graph >::vertex_iterator VertexIterator
const QuantLib::ext::shared_ptr< const CurveConfigurations > curveConfigs_
boost::property_map< Graph, boost::vertex_index_t >::type IndexMap
const QuantLib::ext::shared_ptr< TodaysMarketParameters > params_
friend std::ostream & operator<<(std::ostream &o, const Node &n)
boost::directed_graph< Node > Graph
std::map< std::string, Graph > dependencies_
DependencyGraph(const Date &asof, const QuantLib::ext::shared_ptr< TodaysMarketParameters > ¶ms, const QuantLib::ext::shared_ptr< const CurveConfigurations > &curveConfigs, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig())
boost::graph_traits< Graph >::vertex_descriptor Vertex
const IborFallbackConfig iborFallbackConfig_
static IborFallbackConfig defaultConfig()
Currency and instrument specific conventions/defaults.
Curve configuration repository.
ibor fallback configuration
Serializable Credit Default Swap.
QuantLib::ext::shared_ptr< CurveSpec > curveSpec
vector< string > curveConfigs
A class to hold todays market configuration(s)