/*get the set of documents published by peer p*/ set<int> DBGraph::getsDocsOfPeer(int p){ set<int> docs = getConnectedNodes(p); set<int> final; set<int>::iterator doc; for ( doc=docs.begin() ; doc != docs.end(); doc++ ){ final.insert(*doc * (-1));//add the positive integer corresponding to this doc (stored as negative int) }
/*get connected nodes from a label * */ set<int> GraphInt::getConnectedNodes(int innode){ node_iterator nit = find(innode); //find node "from" //int degre = nit->count_edges(); //cout<<"step1\n"; if (nit==end()) return set<int>(); return getConnectedNodes(nit); }
/* * output graph to ostream; */ void GraphInt::write(std::ostream & os) { os<<"Nodes: connect to: \n"; for (node_iterator ni = begin(); ni!= end(); ni++) // iterate through the nodes { os<<*ni<<" : "; set<int> connections = getConnectedNodes(ni); for (set<int>::iterator nums = connections.begin(); nums!= connections.end(); nums++){ os<<" "<<*nums; } os<<endl; } }
void Node::visitDependenciesUnconditional(std::function<void(std::shared_ptr<Job>&)> &pred) { for(int i = 0; i < getInputConnectionCount(); i++) { auto conn = getInputConnection(i)->getConnectedNodes(); for(auto &p: conn) { auto j = std::dynamic_pointer_cast<Job>(p->shared_from_this()); pred(j); } } for(auto &p: properties) { auto &prop = p.second; auto conn = prop.getInputConnection(); if(conn) { for(auto n: conn->getConnectedNodes()) { auto j = std::dynamic_pointer_cast<Job>(n->shared_from_this()); pred(j); } } } }
int InputConnection::getConnectedNodeCount() { return (int)getConnectedNodes().size(); }