MCPcopy Create free account
hub / github.com/cneben/QuickQanava / collectInnerEdges

Method collectInnerEdges

src/qanGraph.cpp:2011–2040  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2009}
2010
2011auto 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
2042std::vector<const qan::Node*> Graph::collectNeighbours(const qan::Node& node) const
2043{

Callers

nothing calls this directly

Calls 9

get_in_edgesMethod · 0.80
getDestinationMethod · 0.80
get_out_edgesMethod · 0.80
sizeMethod · 0.45
cbeginMethod · 0.45
cendMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
getSourceMethod · 0.45

Tested by

no test coverage detected