/** * Returns the inner segment configuration. * @return inner segment configuration */ unsigned int BOP_Segment::getConfig() { if (isUndefined(m_cfg1)) return m_cfg2; else if (isUndefined(m_cfg2)) return m_cfg1; else if (isVertex(m_cfg1)) { // v1 is vertex if (isVertex(m_cfg2)) { // v2 is vertex return createEdgeCfg(getEdgeBetween(getVertex(m_cfg1),getVertex(m_cfg2))); } else if (isEdge(m_cfg2)) { // v2 is edge if (isOnEdge(m_cfg1,getEdge(m_cfg2))) return m_cfg2; else return createInCfg(); //IN } else return createInCfg(); //IN } else if (isEdge(m_cfg1)) { // v1 is edge if (isVertex(m_cfg2)) { // v2 is vertex if (isOnEdge(m_cfg2,getEdge(m_cfg1))) return m_cfg1; else return createInCfg(); //IN } else if (isEdge(m_cfg2)) { // v2 is edge if (m_cfg1 == m_cfg2) return m_cfg1; else return createInCfg(); // IN } else return createInCfg(); // IN } else return createInCfg(); // IN }
bool VEF::vertexManifoldTest(unsigned int index){ int flag = 0; // if the flag reached 4, the test fails std::vector<Edge> edges; for (unsigned int i = 0; i < m_adjacentFaces[index].size(); i++){ Face *f = getFace(m_adjacentFaces[index][i]); if ((getEdge(f->getA())->getA() != index) && (getEdge(f->getA())->getB() != index)){ // don't add the edge that doesn't contain index edges.push_back(*getEdge(f->getB())); edges.push_back(*getEdge(f->getC())); } else if ((getEdge(f->getB())->getA() != index) && (getEdge(f->getB())->getB() != index)){ edges.push_back(*getEdge(f->getA())); edges.push_back(*getEdge(f->getC())); } else { edges.push_back(*getEdge(f->getA())); edges.push_back(*getEdge(f->getB())); } } for (unsigned int j = 0; j < edges.size(); j++){ for (unsigned int k = 0; k < edges.size(); k++){ if (edges.at(j) == edges.at(k)) break; } flag++; } if (flag < 4) return true; return false; }
/** * Returns the mesh edge on the specified face and relative edge index. * @param face mesh face * @param edge face relative edge index * @return mesh edge on the specified face and relative index, NULL otherwise */ BOP_Edge* BOP_Mesh::getEdge(BOP_Face *face, unsigned int edge) { if (face->size()==3) return getEdge((BOP_Face3 *)face,edge); else return getEdge((BOP_Face4 *)face,edge); }
void Map::draw(float elapsed) { CL_Vec2<float> fieldSize; CL_Pointf p; CL_Rect viewport = window.get_viewport(); fieldSize.x = (float)viewport.get_width() / size.width; fieldSize.y = (float)viewport.get_height() / size.height; for (int row = 0; row < size.height; row++) for (int col = 0; col < size.width; col++) { p = CL_Pointf(col * fieldSize.x, row * fieldSize.y) + fieldSize / 2; if (row < size.height - 1) { CL_Colorf color(getEdge(CL_Point(col, row), CL_Point(col, row + 1)).pheromone / 10, 0, 0); CL_Draw::line(window.get_gc(), p, p + CL_Vec2<float>(0, fieldSize.y), color); } if (col < size.width - 1) { CL_Colorf color(getEdge(CL_Point(col, row), CL_Point(col + 1, row)).pheromone / 10, 0, 0); CL_Draw::line(window.get_gc(), p, p + CL_Vec2<float>(fieldSize.x, 0), color); } } p = CL_Pointf(start.x * fieldSize.x, start.y * fieldSize.y); CL_Draw::fill(window.get_gc(), p, p + fieldSize, CL_Colorf::red); p = CL_Pointf(target.x * fieldSize.x, target.y * fieldSize.y); CL_Draw::fill(window.get_gc(), p, p + fieldSize, CL_Colorf::green); }
bool MSPerson::MSPersonStage_Walking::moveToNextEdge(MSPerson* person, SUMOTime currentTime, MSEdge* nextInternal) { ((MSEdge*)getEdge())->removePerson(person); //std::cout << SIMTIME << " moveToNextEdge person=" << person->getID() << "\n"; if (myRouteStep == myRoute.end() - 1) { MSNet::getInstance()->getPersonControl().unsetWalking(person); if (myDestinationStop != 0) { myDestinationStop->addTransportable(person); } if (!person->proceed(MSNet::getInstance(), currentTime)) { MSNet::getInstance()->getPersonControl().erase(person); } //std::cout << " end walk. myRouteStep=" << (*myRouteStep)->getID() << "\n"; return true; } else { if (nextInternal == 0) { ++myRouteStep; myCurrentInternalEdge = 0; } else { myCurrentInternalEdge = nextInternal; } ((MSEdge*) getEdge())->addPerson(person); return false; } }
void ActiveNode::increaseImplicitNodeOffset(unsigned int edgeIndex) { if(!m_bImplicit)//显示节点 { Edge* pEdge=m_pNode->getChildEdge(edgeIndex); //显示变隐式 if( pEdge->charSize()>1 || pEdge->getVirtualEndPos()==0)//长度大于1,或者儿子为叶子节点 { m_bImplicit=true; m_nImplicitNodeEdge=edgeIndex; m_nImplicitNodeOffsetInEdge=0; } //显示变下一个显示 else//charSize==1 m_pNode=pEdge->getNextNode(); } else { m_nImplicitNodeOffsetInEdge++; if(getEdge()->charSize() == m_nImplicitNodeOffsetInEdge+1)//getEdge()->getEndPos()还没有加入那么多时,用到m_nEndPos是否合适? { setExplicitNode(getEdge()->getNextNode()); } } }
Edge *getNthInEdge(Graph *graph, Node *node, int n) { assert(n >= 0); if(n == 0) return getEdge(graph, node->first_in_edge); else if(n == 1) return getEdge(graph, node->second_in_edge); else { assert(n - 2 < node->in_edges.size); return getEdge(graph, node->in_edges.items[n - 2]); } }
std::vector<m_Edge*> m_Polygon::getNotFacingEdges(vector2f point) { std::vector<m_Edge*> notFacing; for(int i=0; i < getNumVerticies(); i++) { vector2f towards = point - getEdge(i)->getMiddle(); float dot = getNormal(i) * towards; if(dot <= 0) notFacing.push_back(getEdge(i)); } return notFacing; }
void Delaunay::getTriangulation(const vector<double> &attribute){ vector<double> attri_backup=attribute; if(attribute.size()!=0) assert(attribute.size()==(this->vtx.size()-4)); else attri_backup=vector<double>(this->vtx.size()-4,0); triangulation.clear(); int total = (int)(this->qedges.size()*4); vector<bool> edgemask(total, false); // int idx=0; for(int i = 4; i < total; i += 2 ){ if( edgemask[i] ) continue; Point2f pt[3]; int pt_id[3]; int edge = i; pt_id[0]=edgeOrg(edge, &pt[0]); if (pt_id[0]<4) continue; edgeOrg(edge, &pt[0]); edgemask[edge] = true; edge = getEdge(edge, NEXT_AROUND_LEFT); pt_id[1]=edgeOrg(edge, &pt[1]); if(pt_id[1]<4) continue; edgeOrg(edge, &pt[1]); edgemask[edge] = true; edge = getEdge(edge, NEXT_AROUND_LEFT); pt_id[2]=edgeOrg(edge, &pt[2]); if(pt_id[2]<4) continue; edgeOrg(edge, &pt[2]); edgemask[edge] = true; triangle tri; // tri.id=idx++; for(int k=0;k<3;++k){ vertex v; v.id=k; v.pt=pt[k]; v.attr=attri_backup[pt_id[k]-4]; tri.vtx[k]=v; } tri.area=calTriArea(tri.vtx); triangulation.push_back(tri); } }
/** * Returns the mesh edge on the specified triangle and relative edge index. * @param face mesh triangle * @param edge face relative edge index * @return mesh edge on the specified triangle and relative index, NULL otherwise */ BOP_Edge* BOP_Mesh::getEdge(BOP_Face3 *face, unsigned int edge) { switch(edge){ case 1: return getEdge(m_vertexs[face->getVertex(0)]->getEdges(),face->getVertex(1)); case 2: return getEdge(m_vertexs[face->getVertex(1)]->getEdges(),face->getVertex(2)); case 3: return getEdge(m_vertexs[face->getVertex(2)]->getEdges(),face->getVertex(0)); }; return NULL; }
bool Mesh::readPlyFaceList(FILE *&inFile) { int i; for (i = 0; i < m_faceCount; i++) { int vertexIndex1, vertexIndex2, vertexIndex3; int ngon; fscanf(inFile, "%d", &ngon); if (ngon != 3) { std::cerr << "Ply file contains polygons which are not triangles."; return false; } fscanf(inFile, "%d", &vertexIndex1); fscanf(inFile, "%d", &vertexIndex2); fscanf(inFile, "%d", &vertexIndex3); assert(vertexIndex1 < m_vertexCount); assert(vertexIndex2 < m_vertexCount); assert(vertexIndex3 < m_vertexCount); Edge* e12 = getEdge(vertexIndex1, vertexIndex2); if (!e12) { e12 = new Edge(getVertex(vertexIndex1), getVertex(vertexIndex2)); m_edgeList.push_back(e12); } Edge* e23 = getEdge(vertexIndex2, vertexIndex3); if (!e23) { e23 = new Edge(getVertex(vertexIndex2), getVertex(vertexIndex3)); m_edgeList.push_back(e23); } Edge* e31 = getEdge(vertexIndex3, vertexIndex1); if (!e31) { e31 = new Edge(getVertex(vertexIndex3), getVertex(vertexIndex1)); m_edgeList.push_back(e31); } Face* f = new Face(this, vertexIndex1, vertexIndex2, vertexIndex3); m_faceList.push_back(f); if (feof(inFile)) { std::cerr << "Reached EOF before all faces found."; return false; } // read until end of line while (fgetc(inFile) != '\n'); } return true; }
void NIImporter_VISUM::parse_TurnsToSignalGroups() { // get the id std::string SGid = getNamedString("SGNR", "SIGNALGRUPPENNR"); std::string LSAid = getNamedString("LsaNr"); // nodes NBNode* from = myLineParser.know("VonKnot") ? getNamedNode("VonKnot") : 0; NBNode* via = myLineParser.know("KNOTNR") ? getNamedNode("KNOTNR") : getNamedNode("UeberKnot", "UeberKnotNr"); NBNode* to = myLineParser.know("NachKnot") ? getNamedNode("NachKnot") : 0; // edges NBEdge* edg1 = 0; NBEdge* edg2 = 0; if (from == 0 && to == 0) { edg1 = getNamedEdgeContinuating("VONSTRNR", via); edg2 = getNamedEdgeContinuating("NACHSTRNR", via); } else { edg1 = getEdge(from, via); edg2 = getEdge(via, to); } // add to the list NIVisumTL::SignalGroup& SG = myTLS.find(LSAid)->second->getSignalGroup(SGid); if (edg1 != 0 && edg2 != 0) { if (!via->hasIncoming(edg1)) { std::string sid; if (edg1->getID()[0] == '-') { sid = edg1->getID().substr(1); } else { sid = "-" + edg1->getID(); } if (sid.find('_') != std::string::npos) { sid = sid.substr(0, sid.find('_')); } edg1 = getNamedEdgeContinuating(myNetBuilder.getEdgeCont().retrieve(sid), via); } if (!via->hasOutgoing(edg2)) { std::string sid; if (edg2->getID()[0] == '-') { sid = edg2->getID().substr(1); } else { sid = "-" + edg2->getID(); } if (sid.find('_') != std::string::npos) { sid = sid.substr(0, sid.find('_')); } edg2 = getNamedEdgeContinuating(myNetBuilder.getEdgeCont().retrieve(sid), via); } SG.connections().push_back(NBConnection(edg1, edg2)); } }
bool AntiPodalV::isCorrect() const { long xBegin=getEdge().getBegin().getX(); long xEnd=getEdge().getEnd().getX(); long yBegin=getEdge().getBegin().getY(); long yEnd=getEdge().getEnd().getY(); long xVertex=getVertex().getX(); long yVertex=getVertex().getY(); if((xVertex==xBegin)&&(yVertex==yBegin)) return false; if((xVertex==xEnd)&&(yVertex==yEnd)) return false; if((xBegin==xEnd)&&(yBegin=yEnd))return false; if((xVertex-xBegin)*(xVertex-xEnd)>0) return false; return true; }
/** * Adds a new quad. * @param face mesh quad * @return mesh face index */ BOP_Index BOP_Mesh::addFace(BOP_Face4 *face) { m_faces.push_back((BOP_Face *)face); BOP_Index indexface = m_faces.size()-1; BOP_Index index1 = face->getVertex(0); BOP_Index index2 = face->getVertex(1); BOP_Index index3 = face->getVertex(2); BOP_Index index4 = face->getVertex(3); BOP_Index edge; if (!getIndexEdge(index1,index2,edge)) { edge = addEdge(index1,index2); getVertex(index1)->addEdge(edge); getVertex(index2)->addEdge(edge); } getEdge(edge)->addFace(indexface); if (!getIndexEdge(index2,index3,edge)) { edge = addEdge(index2,index3); getVertex(index2)->addEdge(edge); getVertex(index3)->addEdge(edge); } getEdge(edge)->addFace(indexface); if (!getIndexEdge(index3,index4,edge)) { edge = addEdge(index3,index4); getVertex(index3)->addEdge(edge); getVertex(index4)->addEdge(edge); } getEdge(edge)->addFace(indexface); if (!getIndexEdge(index4,index1,edge)) { edge = addEdge(index4,index1); getVertex(index4)->addEdge(edge); getVertex(index1)->addEdge(edge); } getEdge(edge)->addFace(indexface); if ((index1 == index2) || (index1 == index3) || (index1 == index4) || (index2 == index3) || (index2 == index4) || (index3 == index4)) face->setTAG(BROKEN); return m_faces.size()-1; }
void createNetwork::rewireUndirected ( double prop, nodeBlueprint * n ) // rewire für ungerichtete Netzwerke die danach immer noch ungerichtetet sein sollen { network::edgeList allLinks, toChange; network::edgeIterator it; network::edgesBetween ( allLinks, n,n); nodeList vl; network::verticesMatching(vl, n); getRandomNode r (vl); for (it = allLinks.begin(); it != allLinks.end();it++) if (getTarget(*it) > getSource(*it)) toChange.push_back(*it); for ( it = toChange.begin(); it != toChange.end(); it++ ) { if ( network::noise.getUniform() > prop ) continue; nodeDescriptor newSource, oldSource; nodeDescriptor newTarget, oldTarget; oldSource = it->first ; oldTarget = getTarget (*it); do { newSource = r(); newTarget = r(); } while( newSource == newTarget || nodeBlueprint::theNodes[newSource]->isLinked (newTarget )); //keine selfloops und Doppelverbindungen if ( ( newSource == oldSource ) && ( newTarget == oldTarget ) ) continue; network::link ( newSource, newTarget, (edgeBlueprint *)getEdge(*it)); network::link ( newTarget, newSource, (edgeBlueprint *)getEdge(*it)); network::unlink ( oldSource, oldTarget ); network::unlink ( oldTarget, oldSource ); } clean(); }
void VortexSheetMesh::calcVorticity() { for (size_t tri = 0; tri < mTris.size(); tri++) { VortexSheetInfo& v = mVorticity.data[tri]; Vec3 e0 = getEdge(tri,0), e1 = getEdge(tri,1), e2 = getEdge(tri,2); Real area = getFaceArea(tri); if (area < 1e-10) { v.smokeAmount = 0; v.vorticity = 0; } else { v.smokeAmount = 0; v.vorticity = (v.circulation[0]*e0 + v.circulation[1]*e1 + v.circulation[2]*e2) / area; } } }
// Return true if the cut edge at loop[index] is preceded by cuts through // the edge end points. bool Foam::geomCellLooper::edgeEndsCut ( const labelList& loop, const label index ) const { label edgeI = getEdge(loop[index]); const edge& e = mesh().edges()[edgeI]; const label prevCut = loop[loop.rcIndex(index)]; const label nextCut = loop[loop.fcIndex(index)]; if (!isEdge(prevCut) && !isEdge(nextCut)) { // Cuts before and after are both vertices. Check if both // the edge endpoints label v0 = getVertex(prevCut); label v1 = getVertex(nextCut); if ( (v0 == e[0] && v1 == e[1]) || (v0 == e[1] && v1 == e[0]) ) { return true; } } return false; }
void VortexSheetMesh::calcCirculation() { for (size_t tri = 0; tri < mTris.size(); tri++) { VortexSheetInfo& v = mVorticity.data[tri]; Vec3 e0 = getEdge(tri,0), e1 = getEdge(tri,1), e2 = getEdge(tri,2); Real area = getFaceArea(tri); if (area < 1e-10 || normSquare(v.vorticity) < 1e-10) { v.circulation = 0; continue; } float cx, cy, cz; SolveOverconstraint34(e0.x, e0.y, e0.z, e1.x, e1.y, e1.z, e2.x, e2.y, e2.z, v.vorticity.x, v.vorticity.y, v.vorticity.z, cx, cy, cz); v.circulation = Vec3(cx, cy, cz) * area; } }
Node* BaseUkkonen::checkEdge(Node* node, string symbol) { if ( node == dummy ) return root; else return getEdge(node, symbol); }
GUIParameterTableWindow* GUIPerson::getParameterWindow(GUIMainWindow& app, GUISUMOAbstractView&) { GUIParameterTableWindow* ret = new GUIParameterTableWindow(app, *this, 16); // add items //ret->mkItem("type [NAME]", false, myType->getID()); ret->mkItem("stage", false, getCurrentStageDescription()); ret->mkItem("start edge [id]", false, getFromEdge()->getID()); ret->mkItem("dest edge [id]", false, getDestination().getID()); ret->mkItem("edge [id]", false, getEdge()->getID()); ret->mkItem("position [m]", true, new FunctionBinding<GUIPerson, SUMOReal>(this, &GUIPerson::getEdgePos)); ret->mkItem("speed [m/s]", true, new FunctionBinding<GUIPerson, SUMOReal>(this, &GUIPerson::getSpeed)); ret->mkItem("angle [degree]", true, new FunctionBinding<GUIPerson, SUMOReal>(this, &GUIPerson::getNaviDegree)); ret->mkItem("waiting time [s]", true, new FunctionBinding<GUIPerson, SUMOReal>(this, &GUIPerson::getWaitingSeconds)); ret->mkItem("parameters [key:val]", false, toString(getParameter().getMap())); ret->mkItem("", false, ""); ret->mkItem("Type Information:", false, ""); ret->mkItem("type [id]", false, myVType->getID()); ret->mkItem("length", false, myVType->getLength()); ret->mkItem("minGap", false, myVType->getMinGap()); ret->mkItem("maximum speed [m/s]", false, myVType->getMaxSpeed()); ret->mkItem("type parameters [key:val]", false, toString(myVType->getParameter().getMap())); // close building ret->closeBuilding(); return ret; }
void BFS::initializeAnimation(){ setMenu(false); int r=255, g=255, b=0; int color_step= 25; m_operations.push_back([=,this](){ getNode(_currentNode)->setColor(QColor(r, g, b));colorNode(_currentNode); }); r-=color_step; g-=color_step; QQueue<int> queue; queue.append(_currentNode); getNode(_currentNode)->setVisited(true); while(!queue.empty()){ int curr = queue.at(0); queue.pop_front(); NodeList list = getNeighbours(curr); for (auto iter : list){ if(!getNode(iter)->visited()){ getNode(iter)->setVisited(true); m_operations.push_back([=,this](){getEdge(curr, iter)->setColor(QColor(r,g,b)); colorEdge(curr, iter); emit highlightLine(10);}); m_operations.push_back([=,this](){getNode(iter)->setColor(QColor(r,g,b)); colorNode(iter);}); queue.append(iter); } } r-=color_step; g-=color_step; } m_animationInitialized= true; m_currentStepInAnimation= 0; m_numberOfStepsInAnimation= m_operations.size(); }
GraphScene *GraphMlLoader::getGraph() { while(!reader.atEnd() && !reader.hasError()) { QXmlStreamReader::TokenType token = reader.readNext(); if(token == QXmlStreamReader::StartDocument) { continue; } if(token == QXmlStreamReader::StartElement) { if(reader.name() == "key" || reader.name() == "graph") { continue; } if(reader.name() == "node") { getNode(); } if(reader.name() == "edge") { getEdge(); } } } return graph; }
void Tile::disconnect(Tile::Side side, Tile * other, Game * game) { #if PRINT_CONNECTIONS qDebug() << "disconnect tile:" << id << "<->" << other->id; #endif Tile::Side otherSide = sideOpposite(side); Q_ASSERT_X(getEdge(side) == other->getEdge(otherSide), "Tile::connect", "edges don't match"); if (other->cloister != 0) other->cloister->removeSurroundingTile(game); if (cloister != 0) cloister->removeSurroundingTile(game); EdgeType * nodeList = getEdgeNodes(side); EdgeType * otherNodeList = other->getEdgeNodes(otherSide); for (int i = 0; i < EDGE_NODE_COUNT; ++i) { EdgeType thisNode = nodeList[i]; if (isNull(thisNode)) continue; EdgeType otherNode = otherNodeList[EDGE_NODE_COUNT - 1 - i]; #if NODE_VARIANT == 1 (*thisNode)->disconnect(*otherNode, game); #elif NODE_VARIANT == 0 thisNode->disconnect(otherNode, game); #elif NODE_VARIANT == 2 nodes[thisNode]->disconnect(other->nodes[otherNode], game); #endif } }
void printGraph(GraphFlow *g) { int i = 0; int j = 0; printf("-- graph --\n"); printf("-Edges:\n"); for(i=0; i < getNumNodes(g); i++) { for(j=0; i < getNumNodes(g); i++) { printf("%d ", getEdge(g,i,j)); } printf("\n"); } printf("-Capacity:\n"); for(i=0; i < getNumNodes(g); i++) { for(j=0; i < getNumNodes(g); i++) { printf("%d ", getCapacity(g,i,j)); } printf("\n"); } printf("-Flow:\n"); for(i=0; i < getNumNodes(g); i++) { for(j=0; i < getNumNodes(g); i++) { printf("%d ", getFlow(g,i,j)); } printf("\n"); } }
void freeGraph(Graph *graph) { if(graph == NULL) return; int index; for(index = 0; index < graph->nodes.size; index++) { Node *node = getNode(graph, index); if(node == NULL) continue; if(node->out_edges.items != NULL) free(node->out_edges.items); if(node->in_edges.items != NULL) free(node->in_edges.items); removeHostList(node->label.list); } if(graph->nodes.holes.items) free(graph->nodes.holes.items); if(graph->nodes.items) free(graph->nodes.items); for(index = 0; index < graph->edges.size; index++) { Edge *edge = getEdge(graph, index); if(edge == NULL) continue; removeHostList(edge->label.list); } if(graph->edges.holes.items) free(graph->edges.holes.items); if(graph->edges.items) free(graph->edges.items); if(graph->root_nodes != NULL) { RootNodes *iterator = graph->root_nodes; while(iterator != NULL) { RootNodes *temp = iterator; iterator = iterator->next; free(temp); } } free(graph); }
RIFG::NodeId RIFG::getEdgeSink(RIFG::EdgeId eid) const { OA::OA_ptr<OA::DGraph::EdgeInterface> e = getEdge(eid); OA::OA_ptr<OA::DGraph::NodeInterface> n = e->getSink(); return (getNodeId(n)); }
/*simulate a random multi graph following a unique model*/ TypeMultiGraph *getRandomMultiGraphER(double p, int sizeTable, TypeSizeG sizeGraph) { TypeMultiGraph *g; TypeSizeG n, m; int t; g = (TypeMultiGraph*) malloc(sizeof(TypeMultiGraph)); g->sizeGraph = sizeGraph; g->sizeTable = sizeTable; g->name = (char**) malloc(g->sizeGraph*sizeof(char*)); for(n=0; n<g->sizeGraph; n++) { char tmp[100]; sprintf(tmp, "%d", n+1); g->name[n] = (char*) malloc((strlen(tmp)+1)*sizeof(char)); strcpy(g->name[n], tmp); } g->edge = (TypeEdgeG***) malloc(g->sizeTable*sizeof(TypeEdgeG**)); g->present = (int**) malloc(g->sizeTable*sizeof(int*)); for(t=0; t<g->sizeTable; t++) { g->present[t] = (int*) malloc(g->sizeGraph*sizeof(int)); g->edge[t] = (TypeEdgeG**) malloc(g->sizeGraph*sizeof(TypeEdgeG*)); for(n=0; n<g->sizeGraph; n++) { g->present[t][n] = 1; g->edge[t][n] = (TypeEdgeG*) malloc(g->sizeGraph*sizeof(TypeEdgeG)); g->edge[t][n][n] = 0; for(m=0; m<n; m++) { g->edge[t][n][m] = getEdge(p); g->edge[t][m][n] = g->edge[t][n][m]; } } } return g; }
/*simulate a random multi graph following model*/ TypeMultiGraph *getRandomMultiGraph(TypeMultiERMG *model, TypeSizeG sizeGraph, TypePartition *part) { TypeMultiGraph *g; TypeSizeG n, m; char tmp[100]; int t; g = (TypeMultiGraph*) malloc(sizeof(TypeMultiGraph)); g->sizeGraph = sizeGraph; g->sizeTable = model->sizeTable; g->name = NULL; g->edge = (TypeEdgeG***) malloc(g->sizeTable*sizeof(TypeEdgeG**)); g->present = (int**) malloc(g->sizeTable*sizeof(int*)); for(t=0; t<g->sizeTable; t++) { g->present[t] = (int*) malloc(g->sizeGraph*sizeof(int)); g->edge[t] = (TypeEdgeG**) malloc(g->sizeGraph*sizeof(TypeEdgeG*)); for(n=0; n<g->sizeGraph; n++) { g->present[t][n] = 1; g->edge[t][n] = (TypeEdgeG*) malloc(g->sizeGraph*sizeof(TypeEdgeG)); g->edge[t][n][n] = 0; for(m=0; m<n; m++) { g->edge[t][n][m] = getEdge(model->pi[t][part->atom[n]][part->atom[m]]); g->edge[t][m][n] = g->edge[t][n][m]; } } } return g; }
void TRegion::print() { std::cout << "\nNum edges: " << getEdgeCount() << std::endl; for (UINT i = 0; i < getEdgeCount(); i++) { std::cout << "\nEdge #" << i; std::cout << ":P0(" << getEdge(i)->m_s->getChunk(0)->getP0().x << "," << getEdge(i)->m_s->getChunk(0)->getP0().y << ")"; std::cout << ":P2(" << getEdge(i)->m_s->getChunk(getEdge(i)->m_s->getChunkCount() - 1)->getP2().x << "," << getEdge(i)->m_s->getChunk(getEdge(i)->m_s->getChunkCount() - 1)->getP2().y << ")"; std::cout << std::endl; } if (m_imp->m_includedRegionArray.size()) { std::cout << "***** questa regione contiene:" << std::endl; for (UINT i = 0; i < m_imp->m_includedRegionArray.size(); i++) m_imp->m_includedRegionArray[i]->print(); std::cout << "***** fine" << std::endl; } }
PathNode const * PathGraph::getNeighbor ( int nodeIndex, int edgeIndex ) const { PathEdge const * edge = getEdge(nodeIndex,edgeIndex); int neighborIndex = edge->getIndexB(); return getNode(neighborIndex); }