46 for (
const Handle& o : lll->getOutgoingSet())
49 results.insert(results.end(), sub.begin(), sub.end());
72 for (
const Handle& o : lll->getOutgoingSet())
75 results.insert(sub.begin(), sub.end());
96 for (
const Handle& o : lll->getOutgoingSet())
99 results.insert(results.end(), sub.begin(), sub.end());
120 for (
const Handle& o : lll->getOutgoingSet())
123 results.insert(sub.begin(), sub.end());
131 bool fanout,
Type desiredLinkType,
135 throw InvalidParamException(TRACE_INFO,
136 "Handle %d doesn't refer to a Atom", h.
value());
142 Type linkType = link->getType();
143 if ((linkType == desiredLinkType)
144 or (subClasses &&
classserver().isA(linkType, desiredLinkType))) {
145 for (
const Handle& handle : link->getOutgoingSet()) {
146 if (handle == h)
continue;
147 if (!fanout && link->isSource(h))
continue;
148 if (!fanin && link->isTarget(h))
continue;
149 answer.push_back(handle);
157 const std::vector<Type>& types)
164 for (
const Handle& h : link->getOutgoingSet()) {
166 found_nodes.insert(tmp.begin(), tmp.end());
172 OC_ASSERT(
NodeCast(hinput) !=
nullptr);
179 auto it = find(types.begin(), types.end(),
t);
180 if (it != types.end())
202 if (res.find(in_h) == res.cend())
208 for (
const Handle& out_h : link->getOutgoingSet()) {
209 if (res.find(out_h) == res.cend())
229 if (target == NULL) {
230 throw InvalidParamException(TRACE_INFO,
231 "get_predicates: Target handle %d doesn't refer to an Atom", target.
value());
240 Type linkType = link->getType();
241 if (!classServer.
isA(linkType, LIST_LINK))
245 for (
const LinkPtr& evaluationLink : link->getIncomingSet())
248 linkType = evaluationLink->getType();
249 if (!classServer.
isA(linkType, EVALUATION_LINK))
254 Handle candidatePredicate = evaluationLink->getOutgoingAtom(0);
255 Type candidateType = candidatePredicate->
getType();
256 if ((candidateType == predicateType)
258 classServer.
isA(candidateType, predicateType)))
260 answer.push_back(evaluationLink->getHandle());
271 if (target == NULL) {
272 throw InvalidParamException(TRACE_INFO,
273 "get_predicates_for: Target handle %d doesn't refer to an Atom", target.
value());
275 if (predicate == NULL) {
276 throw InvalidParamException(TRACE_INFO,
277 "get_predicates_for: Predicate handle %d doesn't refer to an Atom", predicate.
value());
286 Type linkType = link->getType();
287 if (!classServer.
isA(linkType, LIST_LINK))
291 for (
const LinkPtr& evaluationLink : link->getIncomingSet())
294 linkType = evaluationLink->getType();
295 if (!classServer.
isA(linkType, EVALUATION_LINK))
300 if (predicate == evaluationLink->getOutgoingAtom(0))
301 answer.push_back(evaluationLink->getHandle());
static void get_distant_neighbors_rec(const Handle &h, UnorderedHandleSet &res, int dist)
IncomingSet getIncomingSet()
std::vector< Handle > HandleSeq
a list of handles
HandleSeq get_neighbors(const Handle &h, bool fanin, bool fanout, Type desiredLinkType, bool subClasses)
std::shared_ptr< Link > LinkPtr
ClassServer & classserver(ClassServerFactory *=ClassServer::createInstance)
UnorderedHandleSet get_distant_neighbors(const Handle &h, int dist)
static NodePtr NodeCast(const Handle &h)
HandleSeq get_predicates(const Handle &target, Type predicateType, bool subClasses)
HandleSeq get_all_atoms(Handle h)
HandleSeq get_all_nodes(Handle h)
HandleSeq get_predicates_for(const Handle &target, const Handle &predicate)
bool isA(Type sub, Type super)
UnorderedHandleSet get_outgoing_nodes(const Handle &hinput, const std::vector< Type > &types)
static LinkPtr LinkCast(const Handle &h)
UnorderedHandleSet get_all_unique_nodes(Handle h)
UnorderedHandleSet get_all_unique_atoms(Handle h)
unsigned short Type
type of Atoms, represented as short integer (16 bits)
std::unordered_set< Handle, handle_hash > UnorderedHandleSet
a hash that associates the handle to its unique identificator