38 using SourceCodePath =
typename CodeHandler<Base>::SourceCodePath;
40 std::map<Node*, PathNodeEdges<Base> > graph_;
44 inline bool empty()
const {
45 return graph_.empty();
48 inline void connect(
Node& node,
50 connect(graph_[&node], node, argument);
56 CPPADCG_ASSERT_UNKNOWN(argument < node.
getArguments().size());
57 CPPADCG_ASSERT_UNKNOWN(node.
getArguments()[argument].getOperation() !=
nullptr);
58 CPPADCG_ASSERT_UNKNOWN(&graph_[&node] == &
nodeInfo);
60 nodeInfo.arguments.push_back(argument);
66 inline bool contains(
Node& node)
const {
67 auto it = graph_.find(&node);
68 return it != graph_.end();
72 auto it = graph_.find(&node);
73 if (
it != graph_.end())
80 auto it = graph_.find(&node);
81 if (
it != graph_.end())
87 inline bool erase(
Node& node) {
88 return graph_.erase(&node) > 0;
103 std::vector<SourceCodePath>
paths;
116 paths[0].reserve(20);
118 if (tail->usage.empty()) {
125 if (
paths.size() > 1)
135 auto*
n =
paths[0][0].node;
137 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
140 n =
edges->usage.begin()->node;
147 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
148 CPPADCG_ASSERT_UNKNOWN(!
edges->usage.empty());
166 std::vector<SourceCodePath> findPathUpTo(Node& node,
171 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
173 std::vector<SourceCodePath>
paths;
177 while (!
edges->arguments.empty()) {
178 if (
edges->arguments.size() > 1) {
183 if (
paths.size() == 2) {
208 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
218 for (
const auto&
arg0: tail->usage) {
224 size_t argIndex =
arg0.argIndex;
227 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
232 if(
edges->arguments.size() != 1)
235 if(
edges->usage.empty())
237 n =
edges->usage.begin()->node;
238 argIndex =
edges->usage.begin()->argIndex;
241 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
244 CPPADCG_ASSERT_UNKNOWN(!
edges->arguments.empty());
251 std::reverse(
paths[0].begin(),
paths[0].end());
253 if (
edges->arguments.size() == 1) {
260 paths[1].reserve(20);
273 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);
275 while (!
edges->arguments.empty()) {
281 CPPADCG_ASSERT_UNKNOWN(
edges !=
nullptr);