| 2009 | } |
| 2010 | |
| 2011 | auto Graph::collectInnerEdges(const std::vector<const qan::Node*>& nodes) const -> std::unordered_set<const qan::Edge*> |
| 2012 | { |
| 2013 | // Algorithm: |
| 2014 | // 0. Index nodes |
| 2015 | // 1. For every nodes: |
| 2016 | // 1.1 Collect all out edge where dst is part of nodes |
| 2017 | // 1.2 Collect all in edge where src is part of nodes |
| 2018 | std::unordered_set<const qan::Edge*> innerEdges; |
| 2019 | if (nodes.size() == 0) |
| 2020 | return innerEdges; |
| 2021 | std::unordered_set<const qan::Node*> nodesSet(nodes.cbegin(), nodes.cend()); |
| 2022 | |
| 2023 | std::unordered_set<qan::Edge*> edges; |
| 2024 | for (const auto node: nodes) { |
| 2025 | const auto& inEdges = node->get_in_edges(); |
| 2026 | for (const auto inEdge: inEdges) { |
| 2027 | if (inEdge != nullptr && |
| 2028 | nodesSet.find(inEdge->getDestination()) != nodesSet.end()) |
| 2029 | innerEdges.insert(inEdge); |
| 2030 | } |
| 2031 | |
| 2032 | const auto& outEdges = node->get_out_edges(); |
| 2033 | for (const auto outEdge: outEdges) { |
| 2034 | if (outEdge != nullptr && |
| 2035 | nodesSet.find(outEdge->getSource()) != nodesSet.end()) |
| 2036 | innerEdges.insert(outEdge); |
| 2037 | } |
| 2038 | } |
| 2039 | return innerEdges; |
| 2040 | } |
| 2041 | |
| 2042 | std::vector<const qan::Node*> Graph::collectNeighbours(const qan::Node& node) const |
| 2043 | { |
nothing calls this directly
no test coverage detected