6 #include <boost/graph/adjacency_list.hpp>
7 #include <boost/graph/filtered_graph.hpp>
29 virtual std::shared_ptr<WorkGraph>
Clone()
const;
48 void AddNode(std::shared_ptr<WorkPiece> input, std::string
const& name);
59 void AddEdge(std::string
const& nameFrom,
unsigned int const outputDim, std::string
const& nameTo,
unsigned int const inputDim);
66 bool HasNode(std::string
const& name)
const;
74 std::vector<std::pair<int,int>>
GetEdges(std::string
const& srcName, std::string
const& tgtName);
80 void Visualize(std::string
const& filename)
const;
85 std::vector<std::string>
GetParents(std::string
const& name)
const;
88 std::string
GetParent(std::string
const& name,
int inputIndex)
const;
93 std::vector<std::string>
GetChildren(std::string
const& name)
const;
100 std::shared_ptr<WorkGraph>
DependentCut(std::string
const& nameOut)
const;
107 std::shared_ptr<WorkGraphPiece>
CreateWorkPiece(std::string
const& node)
const;
115 std::shared_ptr<ModGraphPiece>
CreateModPiece(std::string
const& node, std::vector<std::string>
const& inNames = std::vector<std::string>())
const;
123 bool Constant(std::string
const& node)
const;
133 std::shared_ptr<WorkPiece>
GetPiece(std::string
const& name);
136 std::string
GetName(std::shared_ptr<WorkPiece> piece)
const;
140 void Print(std::ostream& fout=std::cout)
const;
146 std::vector<std::pair<std::string, int> >
GetInputNames()
const;
163 void BindNode(std::string
const& nodeName,
164 std::vector<boost::any>
const& x);
175 void BindEdge(std::string
const& nodeName,
176 unsigned int inputDim,
177 boost::any
const& x);
186 std::vector<boost::any>&
GetConstantOutputs(boost::graph_traits<Graph>::vertex_descriptor
const& node)
const;
194 bool Constant(boost::graph_traits<Graph>::vertex_descriptor
const& node)
const;
196 std::shared_ptr<WorkPiece>
GetPiece(boost::graph_traits<Graph>::vertex_descriptor it);
205 void RecursiveCut(
const boost::graph_traits<Graph>::vertex_descriptor& vOld,
const boost::graph_traits<Graph>::vertex_descriptor& vNew, std::shared_ptr<WorkGraph>& newGraph)
const;
213 bool HasNode(boost::graph_traits<Graph>::vertex_iterator& iter, std::string
const& name)
const;
222 bool HasEdge(boost::graph_traits<Graph>::vertex_descriptor
const& vOut, boost::graph_traits<Graph>::vertex_descriptor
const& vIn,
int const inputDim)
const;
229 boost::graph_traits<Graph>::vertex_iterator
GetNodeIterator(std::string
const& name)
const;
230 boost::graph_traits<Graph>::vertex_iterator
GetNodeIterator(std::shared_ptr<WorkPiece> piece)
const;
236 std::vector<std::pair<boost::graph_traits<Graph>::vertex_descriptor,
int> >
GraphInputs()
const;
242 std::vector<std::pair<boost::graph_traits<Graph>::vertex_descriptor,
int> >
GraphOutputs()
const;
A muq::Modeling::ModPiece created from a muq::Modeling::WorkGraph.
A muq::Modeling::WorkPiece created from a muq::Modeling::WorkGraph.
A graph of connected muq::Modeling::WorkPiece's.
std::vector< std::pair< std::string, int > > GetOutputNames() const
Find the outputs to the graph.
void AddNode(std::shared_ptr< WorkPiece > input, std::string const &name)
Add a new node to the graph.
void AddEdge(std::string const &nameFrom, unsigned int const outputDim, std::string const &nameTo, unsigned int const inputDim)
Add a new edge to the graph.
unsigned int NumEdges() const
Get the number of edgess in the graph.
std::shared_ptr< WorkGraph > DependentCut(std::string const &nameOut) const
Create a new graph cutting any of the nodes that do not affect the output node.
virtual std::shared_ptr< WorkGraph > Clone() const
Graph graph
The directed graph that represents this muq::Modeling::Core::WorkGraph.
std::shared_ptr< ModGraphPiece > CreateModPiece(std::string const &node, std::vector< std::string > const &inNames=std::vector< std::string >()) const
Create a muq::Modeling::ModPiece whose output matches a given node.
std::shared_ptr< WorkPiece > GetPiece(std::string const &name)
void RemoveNode(std::string const &name)
void BindEdge(std::string const &nodeName, unsigned int inputDim, boost::any const &x)
std::string GetParent(std::string const &name, int inputIndex) const
std::vector< std::pair< std::string, int > > GetInputNames() const
Find the inputs to the graph.
std::string GetName(std::shared_ptr< WorkPiece > piece) const
bool HasEdge(boost::graph_traits< Graph >::vertex_descriptor const &vOut, boost::graph_traits< Graph >::vertex_descriptor const &vIn, int const inputDim) const
Is there an edge between two vertices?
void Print(std::ostream &fout=std::cout) const
void Visualize(std::string const &filename) const
Visualize the graph.
boost::graph_traits< Graph >::vertex_iterator GetNodeIterator(std::string const &name) const
Get a vertex_iterator to the node with name "name".
void RecursiveCut(const boost::graph_traits< Graph >::vertex_descriptor &vOld, const boost::graph_traits< Graph >::vertex_descriptor &vNew, std::shared_ptr< WorkGraph > &newGraph) const
Recursively go upstream from a node, copying nodes.
std::shared_ptr< WorkGraphPiece > CreateWorkPiece(std::string const &node) const
Create a muq::Modeling::WorkPiece whose output matches a given node.
std::vector< std::string > GetChildren(std::string const &name) const
std::vector< std::pair< int, int > > GetEdges(std::string const &srcName, std::string const &tgtName)
Returns all edges going from node name1 to node name2.
std::vector< boost::any > const & GetConstantOutputs(std::string const &node) const
Get the output values for a constant node.
std::vector< std::pair< boost::graph_traits< Graph >::vertex_descriptor, int > > GraphInputs() const
Find the inputs to the graph.
std::vector< std::pair< boost::graph_traits< Graph >::vertex_descriptor, int > > GraphOutputs() const
Find the outputs to the graph.
std::vector< std::string > GetParents(std::string const &name) const
void BindNode(std::string const &nodeName, std::vector< boost::any > const &x)
unsigned int NumNodes() const
Get the number of nodes in the graph.
bool Constant(std::string const &node) const
Check to see if a node is constant?
bool HasNode(std::string const &name) const
Is the given node in the graph?
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, std::shared_ptr< WorkGraphNode >, std::shared_ptr< WorkGraphEdge > > Graph
Define a directed graph type.