Exemple #1
0
void create_new_leaf_here(int ch)
{
    assert (!can_go(ch));
    if (current_vertex != -1)
        edges[current_vertex][ch] = newEdge(current_vertex, current_letter);
    else if (current_edge != -1)
    {
        vertex new_vertex = newVertex(vdepth[from[current_edge]] + depth);
        if (last_vertex != -1)
        {
            suf[last_vertex] = new_vertex;
            last_vertex = -1;
        }

        edge new_edge = newEdge2(new_vertex, to[current_edge], left[current_edge] + depth, right[current_edge]);
        int old_symbol = s[left[new_edge]];
        edges[new_vertex][old_symbol] = new_edge;
        edges[new_vertex][ch] = newEdge(new_vertex, current_letter);
        to[current_edge] = new_vertex;
        right[current_edge] = left[current_edge] + depth;
        current_vertex = new_vertex;
        last_edge = current_edge;
        last_depth = depth;
        current_edge = -1;
        depth = 0;
        last_vertex = new_vertex;
    }
}
Exemple #2
0
void PlanRep::restoreDeg1Nodes(Stack<Deg1RestoreInfo> &S, List<node> &deg1s)
{
	while(!S.empty())
	{
		Deg1RestoreInfo info = S.pop();
		adjEntry adjRef = info.m_adjRef;
		node     vOrig  = info.m_deg1Original;
		edge     eOrig  = info.m_eOriginal;

		node v = newNode(vOrig);

		if(adjRef) {
			if(vOrig == eOrig->source())
				newEdge(eOrig, v, adjRef);
			else
				newEdge(eOrig, adjRef, v);
		} else {
			if(vOrig == eOrig->source())
				newEdge(eOrig);
			else
				newEdge(eOrig);
		}
		deg1s.pushBack(v);
	}
}
Exemple #3
0
	// Create edges
	forall_nodes(v,G) {
		node    vH = m_copy[v];
		cluster c  = CG.clusterOf(v);

		newEdge(m_topNode[c], vH);
		newEdge(vH, m_bottomNode[c]);
	}
Exemple #4
0
typename PolygonMesh<PointType>::VertexIterator PolygonMesh<PointType>::splitFace(const typename PolygonMesh<PointType>::FaceIterator& faceIt,typename PolygonMesh<PointType>::Vertex* facePoint)
	{
	/* Link the face point to the mesh: */
	facePoint->pred=lastVertex;
	facePoint->succ=0;
	if(lastVertex!=0)
		lastVertex->succ=facePoint;
	else
		vertices=facePoint;
	lastVertex=facePoint;

	/* Create a fan of triangles around the face point: */
	Edge* firstOuterEdge=faceIt->getEdge();
	deleteFace(faceIt.face);
	Edge* outerEdge=firstOuterEdge;
	Edge* firstInnerEdge;
	Edge* lastInnerEdge=0;
	do
		{
		Edge* nextOuterEdge=outerEdge->getFaceSucc();
		
		/* Create a new triangle: */
		Face* triangle=newFace();
		Edge* innerEdge1=newEdge();
		Edge* innerEdge2=newEdge();
		facePoint->setEdge(innerEdge1);
		innerEdge1->set(facePoint,triangle,innerEdge2,outerEdge,lastInnerEdge);
		innerEdge1->sharpness=0;
		if(lastInnerEdge!=0)
			lastInnerEdge->setOpposite(innerEdge1);
		else
			firstInnerEdge=innerEdge1;
		innerEdge2->set(outerEdge->getEnd(),triangle,outerEdge,innerEdge1,0);
		innerEdge2->sharpness=0;
		outerEdge->setFace(triangle);
		outerEdge->setFacePred(innerEdge1);
		outerEdge->setFaceSucc(innerEdge2);
		triangle->setEdge(outerEdge);
		
		#ifndef NDEBUG
		triangle->checkFace();
		#endif
		
		lastInnerEdge=innerEdge2;
		outerEdge=nextOuterEdge;
		}
	while(outerEdge!=firstOuterEdge);
	
	/* Close the fan by connecting the first and last inner edges: */
	lastInnerEdge->setOpposite(firstInnerEdge);
	firstInnerEdge->setOpposite(lastInnerEdge);
	
	#ifndef NDEBUG
	facePoint->checkVertex();
	#endif
	
	return VertexIterator(facePoint);
	}
/**
 * Constructs the dihedron
 * @param vertex the dihedron
 */
void ConvexHull::constDihedron(int iv) {
    int kv[] = { iv, iv+1, iv+2 };
    
    // entries cyclic list of vertices
    for (int i = 0; i < NDV; i++) {
        int nxv = kv[(i+1)%NDV];
        khnv[kv[i]] = nxv;
        khpv[nxv]  = kv[i];
    }
    
    // gets index of new edges and faces
    int ke[] = { newEdge(), newEdge(), newEdge() };
    int kf[] = { newFace(), newFace() };
    
    // connects faces to edges
    kfe[kf[0]] = ke[0];
    kfe[kf[1]] = ke[0];
    
    // connects vertices to edges
    kve[kv[0]] = ke[0];
    kve[kv[1]] = ke[1];
    kve[kv[2]] = ke[2];
    
    // connects edges to start and end vertices
    ksv[ke[0]] = kv[0];
    ksv[ke[1]] = kv[1];
    ksv[ke[2]] = kv[2];
    kev[ke[0]] = kv[1];
    kev[ke[1]] = kv[2];
    kev[ke[2]] = kv[0];
    
    // connects edges to left and right faces
    klf[ke[0]] = kf[1];
    klf[ke[1]] = kf[1];
    klf[ke[2]] = kf[1];
    krf[ke[0]] = kf[0];
    krf[ke[1]] = kf[0];
    krf[ke[2]] = kf[0];

    // connects edges to contiguous edges
    ksce[ke[0]]  = ke[2];
    ksce[ke[1]]  = ke[0];
    ksce[ke[2]]  = ke[1];
    kscce[ke[0]] = ke[2];
    kscce[ke[1]] = ke[0];
    kscce[ke[2]] = ke[1];
    kece[ke[0]]  = ke[1];
    kece[ke[1]]  = ke[2];
    kece[ke[2]]  = ke[0];
    kecce[ke[0]] = ke[1];
    kecce[ke[1]] = ke[2];
    kecce[ke[2]] = ke[0];
    
    // entries cyclic list of vertices on the silhouette of the convex hull
    // entries a left most vertex
    kch.push_back(searchSilhouette(NDV, kv));
}
Exemple #6
0
	forall_clusters(c,CG) {
		if(c != CG.rootCluster()) {
			cluster u = c->parent();

			newEdge(m_topNode[u], m_topNode[c]);
			newEdge(m_bottomNode[c], m_bottomNode[u]);

			newEdge(m_topNode[c], m_bottomNode[c]);
		}
	}
// embeds constraint graph such that all sources and sinks lie in a common
// face
void CompactionConstraintGraphBase::embed()
{
	NodeArray<bool> onExternal(*this,false);
	const CombinatorialEmbedding &E = *m_pOR;
	face fExternal = E.externalFace();

	for(adjEntry adj : fExternal->entries)
		onExternal[m_pathNode[adj->theNode()]] = true;

	// compute lists of sources and sinks
	SList<node> sources, sinks;

	for(node v : nodes) {
		if (onExternal[v]) {
			if (v->indeg() == 0)
				sources.pushBack(v);
			if (v->outdeg() == 0)
				sinks.pushBack(v);
		}
	}

	// determine super source and super sink
	node s,t;
	if (sources.size() > 1)
	{
		s = newNode();
		for (node v : sources)
			newEdge(s,v);
	}
	else
		s = sources.front();

	if (sinks.size() > 1)
	{
		t = newNode();
		for (node v : sinks)
			newEdge(v,t);
	}
	else
		t = sinks.front();

	edge st = newEdge(s,t);

	bool isPlanar = planarEmbed(*this);
	if (!isPlanar) OGDF_THROW(AlgorithmFailureException);


	delEdge(st);
	if (sources.size() > 1)
		delNode(s);
	if (sinks.size() > 1)
		delNode(t);
}
Exemple #8
0
/* Draws a triangle with bottom vertex b, top vertex t, and point
   m to the right of line from b to t */
void drawRightTriangle(vertex* b, vertex* t, vertex* m) {
  edge* lEdge;
  edge* rEdge;
  int y;

  /* Draw rows from bottom-top edge to bottom-middle edge */
  lEdge = newEdge(b,t);
  rEdge = newEdge(b,m);

  for (y=b->y; y<m->y; y++) {
    vertex* result = (vertex*)malloc(sizeof(vertex));
	vertex* result1 = (vertex*)malloc(sizeof(vertex));
//	result->v_color = *(interpolate(t, b, lEdge->x));
//	result1->v_color = *(interpolate(m, b, rEdge->x));
	result->v_color = *(integerInt(t, b, lEdge->x, y));
	result1->v_color = *(integerInt(m, b, rEdge->x, y));
	result->y = y;
	result1->y = y;
	result->x = lEdge->x;
	result1->x = rEdge->x;
	drawIRow(result,result1,y);
	free(result);
	free(result1);
    yInc(lEdge);
    yInc(rEdge);
  }
  free(rEdge);

  /* Draw rows from bottom-top edge to middle-top edge */
  rEdge = newEdge(m,t);
  for (; y<=t->y;y++) {
	vertex* result = (vertex*)malloc(sizeof(vertex));
	vertex* result1 = (vertex*)malloc(sizeof(vertex));
//	result->v_color = *(interpolate(t, b, lEdge->x));
//	result1->v_color = *(interpolate(t, m, rEdge->x));
	result->v_color = *(integerInt(t, b, lEdge->x, y));
	result1->v_color = *(integerInt(t, m, rEdge->x, y));
	result->y = y;
	result1->y = y;
	result->x = lEdge->x;
	result1->x = rEdge->x;
	drawIRow(result,result1,y);
	free(result);
	free(result1);
	//drawRow(lEdge->x,rEdge->x, y);
    yInc(lEdge);
    yInc(rEdge);
  }

  free(lEdge);
  free(rEdge);
}
Exemple #9
0
/////////////MAKEMIDPOINTS////////////////////////////////
// makeMidPoints: interface to this class. Set midpoints of every
//                node in this layer.
void
SpatialEdge::makeMidPoints()
{
  size_t c=0;
  size_t index;

  // build up the new edges 

  index = (size_t)LAYER.firstIndex_;
  for(size_t i=0; i < LAYER.nNode_; i++,index++){
    c = newEdge(c,index,0);
    c = newEdge(c,index,1);
    c = newEdge(c,index,2);
  }
}
Exemple #10
0
void addSubgraph(Graph* graph, nodeid_t node_id, xid_t* xids, int n_xids)
{
    xid_t *last = xids + n_xids;
    Edge *e, *next, *edges = NULL;
    Node* node = findNode(&cluster, node_id);
    while (xids != last) { 
        Vertex* src = findVertex(graph, *xids++);
        xid_t xid;
        while ((xid = *xids++) != 0) { 
            Vertex* dst = findVertex(graph, xid);
            e = newEdge(graph);
            dst->nIncomingEdges += 1;
            e->dst = dst;
            e->src = src;
            e->next = edges;
            edges = e;
            l2_list_link(&src->outgoingEdges, &e->node);
        }
    }
    for (e = node->edges; e != NULL; e = next) { 
        next = e->next;
        l2_list_unlink(&e->node);
        if (--e->dst->nIncomingEdges == 0 && l2_list_is_empty(&e->dst->outgoingEdges)) {
            freeVertex(graph, e->dst);
        }
        if (e->dst != e->src && e->src->nIncomingEdges == 0 && l2_list_is_empty(&e->src->outgoingEdges)) {
            freeVertex(graph, e->src);
        }
        freeEdge(graph, e);
    }
    node->edges = edges;
}
/**
 * Merges 2 adjacent convex hulls
 * @param vertex of the left convex hull
 * @param vertex of the right convex hull
 */
void ConvexHull::merge2Hulls(int liv0, int riv0) {
    int liv = liv0;
    int livr = liv0;
    // searches the right most vertex of the left convex hull
    do {
        liv = kcnxv[liv];
        if (hva[livr].x() < hva[liv].x()) {
            livr = liv;
        }
    } while (liv != liv0);
    int liv1 = livr;  int liv2 = livr;
    int riv1 = riv0;  int riv2 = riv0;
    // searches the common tangent edge
    searchCTEdge(liv1, kccnxv, riv1, kcnxv , false);
    searchCTEdge(liv2, kcnxv , riv2, kccnxv, true);
    kcnxv[liv1]  = riv1;
    kccnxv[riv1] = liv1;
    kcnxv[riv2]  = liv2;
    kccnxv[liv2] = riv2;
    int cte = newEdge();
    ksv[cte] = liv1;
    kev[cte] = riv1;
    kep[cte] = PrimProperty::NEW;
    // wraps 2 convex hulls in cylindrical
    wrapInCylindrical(cte);
    // deletes non convex hull primitives
    deleteNonHullPrims(liv1, cte, ScanDir::CW);
    deleteNonHullPrims(riv1, cte, ScanDir::CCW);
    // updates convex hull primitives
    updatePrimitives(cte);
}
Exemple #12
0
struct Edge *Graph_addEdge(struct Graph *self, int idSource, int idSink, double cost){
    struct Edge *edge = NULL;
    struct EdgeLink *edgeLinkToSet, *edgeLinkToList, *edgeLink;
    
    if (idSource >= self->nodeNum || idSink >= self->nodeNum) {
        return NULL;
    }
    
    edge = newEdge(idSource, idSink, cost);
    
    edgeLinkToSet = (struct EdgeLink*)malloc(sizeof(struct EdgeLink));
    edgeLinkToSet->edge = edge;
    edgeLinkToList = (struct EdgeLink*)malloc(sizeof(struct EdgeLink));
    edgeLinkToList->edge = edge;
    
    
    //add to edgeSet
    edgeLink = self->edgeSet;
    self->edgeSet = edgeLinkToSet;
    edgeLinkToSet->next = edgeLink;
    
    //add to node edge List
    edgeLink = self->nodeEdgeList[idSource];
    self->nodeEdgeList[idSource] = edgeLinkToList;
    edgeLinkToList->next = edgeLink;
    
    return edge;
}
Exemple #13
0
std::shared_ptr<WindowEdge> WindowEdge::split(size_t nPreceding, size_t nFollowing)
{
    assert(_instanceIDs.size() == _valueCoords.size() && _values.size()>=_valueCoords.size() && _values.size() == nPreceding + nFollowing);

    std::shared_ptr<WindowEdge> newEdge ( new WindowEdge());
    newEdge->_values.assign(_values.begin(), _values.end());
    newEdge->_valueCoords.assign(_valueCoords.begin() + nPreceding, _valueCoords.end());
    newEdge->_instanceIDs.assign(_instanceIDs.begin() + nPreceding, _instanceIDs.end());
    if(newEdge->_valueCoords.size())
    {
        newEdge->_numFollowing = safe_static_cast<uint32_t>(newEdge->_valueCoords.size() -1);
    }
    else
    {
        newEdge->_numFollowing =0;
    }

    _valueCoords.erase(_valueCoords.begin() + nPreceding, _valueCoords.end());
    _instanceIDs.erase(_instanceIDs.begin() + nPreceding, _instanceIDs.end());
    if(_valueCoords.size())
    {
        _numFollowing = safe_static_cast<uint32_t>(_values.size()-1);
    }
    else
    {
        _numFollowing = safe_static_cast<uint32_t>(_values.size());
    }
    return newEdge;
}
Exemple #14
0
int ChainSilhouetteIterator::traverse(const AdjacencyIterator& ait)
{
	AdjacencyIterator it(ait);
	ViewVertex *nextVertex = getVertex();
	// we can't get a NULL nextVertex here, it was intercepted before
	if (nextVertex->getNature() & Nature::T_VERTEX) {
		TVertex *tvertex = (TVertex *)nextVertex;
		ViewEdge *mate = (tvertex)->mate(getCurrentEdge());
		while (!it.isEnd()) {
			ViewEdge *ve = *it;
			if (ve == mate) {
				result = ve;
				return 0;
			}
			++it;
		}
		result = 0;
		return 0;
	}
	if (nextVertex->getNature() & Nature::NON_T_VERTEX) {
		//soc NonTVertex *nontvertex = (NonTVertex*)nextVertex;
		ViewEdge *newEdge(0);
		// we'll try to chain the edges by keeping the same nature...
		// the preseance order is : SILHOUETTE, BORDER, CREASE, SUGGESTIVE, VALLEY, RIDGE
		Nature::EdgeNature natures[6] = {
			Nature::SILHOUETTE,
			Nature::BORDER,
			Nature::CREASE,
			Nature::SUGGESTIVE_CONTOUR,
			Nature::VALLEY,
			Nature::RIDGE
		};
		for (unsigned int i = 0; i < 6; ++i) {
			if (getCurrentEdge()->getNature() & natures[i]) {
				int n = 0;
				while (!it.isEnd()) {
					ViewEdge *ve = *it;
					if (ve->getNature() & natures[i]) {
						++n;
						newEdge = ve;
					}
					++it;
				}
				if (n == 1) {
					result = newEdge;
				}
				else {
					result = 0;
				}
				return 0;
			}
		}
	}
	result = 0;
	return 0;
}
Exemple #15
0
// builds expansion graph of i-th biconnected component of the original graph
void ExpansionGraph::init(int i)
{
	OGDF_ASSERT(0 <= i);
	OGDF_ASSERT(i <= m_component.high());

	// remove previous component
	for(node v : nodes) {
		node vOrig = m_vOrig[v];
		if (vOrig)
			m_vCopy[vOrig] = nullptr;
	}
	clear();


	// create new component
	SListConstIterator<edge> it;
	for(it = m_component[i].begin(); it.valid(); ++it)
	{
		edge e = *it;

		edge eCopy = newEdge(getCopy(e->source()),getCopy(e->target()));
		m_eOrig[eCopy] = e;
	}

	// expand vertices
	for(node v : nodes)
	{
		if (original(v) && v->indeg() >= 1 && v->outdeg() >= 1) {
			node vPrime = newNode();
			m_vRep[vPrime] = m_vOrig[v];

			SListPure<edge> edges;
			v->outEdges(edges);

			SListConstIterator<edge> it;
			for(it = edges.begin(); it.valid(); ++it)
				moveSource(*it,vPrime);

			newEdge(v,vPrime);
		}
	}
}
Exemple #16
0
void PolygonMesh<PointType>::triangulateFace(const typename PolygonMesh<PointType>::FaceIterator& fIt)
	{
	/* Set up an initial triangle at the face's base point: */
	Face* f=&(*fIt);
	Edge* e1=f->getEdge();
	Vertex* v0=e1->getStart();
	Edge* e2=e1->getFaceSucc();
	Vertex* v1=e2->getStart();
	Edge* e3=e2->getFaceSucc();
	Vertex* v2=e3->getStart();
	Edge* lastEdge=e1->getFacePred();
	
	/* Walk around face: */
	while(e3!=lastEdge)
		{
		/* Chop triangle (v0,v1,v2) off face: */
		Edge* ne1=newEdge();
		Edge* ne2=newEdge();
		Face* nf=newFace();
		nf->setEdge(e1);
		e1->setFace(nf);
		e1->setFacePred(ne1);
		e2->setFace(nf);
		e2->setFaceSucc(ne1);
		ne1->set(v2,nf,e2,e1,ne2);
		ne1->sharpness=0;
		f->setEdge(ne2);
		
		/* Reconnect old face: */
		ne2->set(v0,f,lastEdge,e3,ne1);
		ne2->sharpness=0;
		e3->setFacePred(ne2);
		lastEdge->setFaceSucc(ne2);
		
		/* Move to next triangle: */
		e1=ne2;
		v1=v2;
		e2=e3;
		e3=e3->getFaceSucc();
		v2=e3->getStart();
		}
	}
/**
 * Wraps 2 convex hulls in cylindrical
 * @param common tangent edge
 */
void ConvexHull::wrapInCylindrical(int cte0) {
    int cte1 = cte0;
    int cte2 = cte0;
    int liv0 = ksv[cte0];
    int riv0 = kev[cte0];
    int liv1 = liv0;
    int riv1 = riv0;
    do {
        cte1 = cte2;
        
        // searches the edge of the common tangent face
        int le = searchEdgeOfCTFace(liv1, riv1, ScanDir::CW);
        int re = searchEdgeOfCTFace(riv1, liv1, ScanDir::CCW);
        int liv2 = (liv1 == ksv[le] ? kev[le] : ksv[le]);
        int riv2 = (riv1 == ksv[re] ? kev[re] : ksv[re]);
        
        // searches the exterior edge of the common tangent face
        int kv[] = { riv1, liv1, riv2, liv2 };
        Vector3d va[] = { hva[kv[0]], hva[kv[1]], hva[kv[2]], hva[kv[3]] };
        bool lext = determ(kv, va);
        if (lext) {
            kep[le] = PrimProperty::BOUNDARY;
            liv1 = liv2;
        } else {
            kep[re] = PrimProperty::BOUNDARY;
            riv1 = riv2;
        }
        // entries new common tangent face
        int f = newFace();
        kfp[f] = PrimProperty::NEW;
        if (liv1 == liv0 && riv1 == riv0) {
            cte2 = cte0;
        } else {
            cte2 = newEdge();
            kep[cte2] = PrimProperty::NEW;
        }
        klf[cte2] = f;
        krf[cte1] = f;
        kfe[f]    = cte2;
        ksv[cte2] = liv1;
        kev[cte2] = riv1;
        if (lext) {
            kscce[cte2] = le;
            ksce[cte1]  = le;
            kece[cte2]  = cte1;
            kecce[cte1] = cte2;
        } else {
            kece[cte2]  = re;
            kecce[cte1] = re;
            kscce[cte2] = cte1;
            ksce[cte1]  = cte2;
        }
    } while (cte2 != cte0);
}
Exemple #18
0
static struct phyloTree *parseSubTree(char **ptrPtr)
/* the recursive workhorse function, parses a tree from ptr */
{
struct phyloTree *node = NULL;
char *ptr = *ptrPtr;

/* trees are terminated by one of these three chars */
if ((*ptr == ';') || (*ptr == ',') || (*ptr == ')') )
    return NULL;

AllocVar(node);
if (*ptr == '(') 
    {
    struct phyloTree *edge;

    ptr++;

    do
	{
	struct phyloTree *child = parseSubTree(&ptr);
	if (!child)
	    errAbort("missing child/subTree at (%s)",ptr-1);
	edge = newEdge(node,child);
	edge->parent = node;
	} while (*ptr++ == ',');
    --ptr;
    if (*ptr++ != ')') 
	errAbort("unbalanced parenthesis at (%s)",ptr-1);
    node->ident = parseIdent(&ptr);
    }
else 
    if ((*ptr == ':') || (isalpha(*ptr))|| (isdigit(*ptr)) 
	 || (*ptr == '\'') || (*ptr == '.'))
	node->ident = parseIdent(&ptr);
else
    errAbort("illegal char '%c' in phyloString",*ptr);

if (*ptr == '[')
    {
    if (startsWith("[&&NHX:D=Y]",ptr))
	node->isDup = TRUE;

    while(*ptr != ']')
	ptr++;

    ptr++;

    }

*ptrPtr = ptr;


return node;
}
Exemple #19
0
void addEdge(int u,int v)
{
    E[Ecou].to=v;
    E[Ecou].next=head[u];
    bridge[Ecou]=0;

    chongE[Ecou]=0;
    remE[Ecou]=newEdge(u,v,Ecou);

    head[u]=Ecou++;
}
Exemple #20
0
typename PolygonMesh<PointType>::VertexIterator PolygonMesh<PointType>::splitEdge(const typename PolygonMesh<PointType>::EdgeIterator& edgeIt,typename PolygonMesh<PointType>::Vertex* edgePoint)
	{
	/* Link vertex to mesh: */
	edgePoint->pred=lastVertex;
	edgePoint->succ=0;
	if(lastVertex!=0)
		lastVertex->succ=edgePoint;
	else
		vertices=edgePoint;
	lastVertex=edgePoint;
	
	Edge* edge1=edgeIt.edge;
	Vertex* vertex1=edge1->getStart();
	Edge* edge2=edge1->getOpposite();
	Vertex* vertex2=edge2->getStart();
	Edge* edge3=newEdge();
	Edge* edge4=newEdge();
	
	/* Split edge1 and edge2: */
	edgePoint->setEdge(edge3);
	edge3->set(edgePoint,edge1->getFace(),edge1,edge1->getFaceSucc(),edge2);
	edge3->sharpness=edge1->sharpness;
	edge4->set(edgePoint,edge2->getFace(),edge2,edge2->getFaceSucc(),edge1);
	edge4->sharpness=edge2->sharpness;
	edge1->setFaceSucc(edge3);
	edge1->setOpposite(edge4);
	edge2->setFaceSucc(edge4);
	edge2->setOpposite(edge3);
	edge3->getFaceSucc()->setFacePred(edge3);
	edge4->getFaceSucc()->setFacePred(edge4);
	
	#ifndef NDEBUG
	vertex1->checkVertex();
	vertex2->checkVertex();
	edgePoint->checkVertex();
	edge1->getFace()->checkFace();
	edge2->getFace()->checkFace();
	#endif
	
	return VertexIterator(edgePoint);
	}
Exemple #21
0
void PlanRep::collapseVertices(const OrthoRep &OR, GridLayout &drawing)
{
	for (node v : nodes) {
		const OrthoRep::VertexInfoUML *vi = OR.cageInfo(v);

		if(vi == nullptr ||
			(typeOf(v) != Graph::highDegreeExpander &&
			typeOf(v) != Graph::lowDegreeExpander))
			continue;

		node vOrig = original(v);
		OGDF_ASSERT(vOrig != 0);

		node vCenter = newNode();
		m_vOrig[vCenter] = vOrig;
		m_vCopy[vOrig] = vCenter;
		m_vOrig[v] = nullptr;

		node lowerLeft  = vi->m_corner[odNorth]->theNode();
		node lowerRight = vi->m_corner[odWest ]->theNode();
		node upperLeft  = vi->m_corner[odEast ]->theNode();
		drawing.x(vCenter) = (drawing.x(lowerLeft)+drawing.x(lowerRight)) >> 1;
		drawing.y(vCenter) = (drawing.y(lowerLeft)+drawing.y(upperLeft )) >> 1;

		edge eOrig;
		forall_adj_edges(eOrig,vOrig) {
			if(eOrig->target() == vOrig) {
				node connect = m_eCopy[eOrig].back()->target();
				edge eNew = newEdge(connect,vCenter);
				m_eOrig[eNew] = eOrig;
				m_eIterator[eNew] = m_eCopy[eOrig].pushBack(eNew);

			} else {
				node connect = m_eCopy[eOrig].front()->source();
				edge eNew = newEdge(vCenter,connect);
				m_eOrig[eNew] = eOrig;
				m_eIterator[eNew] = m_eCopy[eOrig].pushFront(eNew);
			}
		}
	}
}
Exemple #22
0
void FaceSinkGraph::doInit()
{
	const ConstCombinatorialEmbedding &E = *m_pE;

	NodeArray<node> sinkSwitch(E,nullptr); // corresponding node in F (if any)
	NodeArray<bool> isSinkSwitch(E,true);

	NodeArray<int> visited(E,-1);
	int faceNo = -1;
	for(face f : E.faces)
	{
		faceNo++;
		node faceNode = newNode();
		m_originalFace[faceNode] = f;

		SListPure<node> nodesInF;

		adjEntry adj1 = f->firstAdj(), adj = adj1;
		do {
			node v = adj->theNode();
			// if the graph is not biconnected, then node v can visited more than once
			if (visited[v] != faceNo) {
				nodesInF.pushBack(v);
				visited[v] = faceNo;
			}

			if (v == m_source)
				m_containsSource[faceNode] = true;

			isSinkSwitch[adj->theEdge()->source()] = false;

			adj = adj->twin()->cyclicPred();
		} while (adj != adj1);

		SListConstIterator<node> it;
		for(it = nodesInF.begin(); it.valid(); ++it)
		{
			node v = *it;
			if(isSinkSwitch[v])	{
				if (sinkSwitch[v] == nullptr) {
					node vF = newNode();
					m_originalNode[vF] = v;
					sinkSwitch[v] = vF;
				}

				newEdge(faceNode,sinkSwitch[v]);
			}
		}

		for(it = nodesInF.begin(); it.valid(); ++it)
			isSinkSwitch[*it] = true;
	}
}
Exemple #23
0
/*
 * Append edgeSet at end of the edgeSet list, returns a pointer 
 * to the edge just added
 */
edgeSet * appendEdgeSet(edgeSet **head, int id)
{
  if((*head)==NULL)
  {    
    (*head) = newEdge(id);
    return (*head);
  }
  else
  {
    return appendEdgeSet(&(*head)->nextEdge, id);
  }
}
Exemple #24
0
// builds expansion graph of graph G
// for debugging purposes only
void ExpansionGraph::init(const Graph &G)
{
	// remove previous component
	for(node v : nodes) {
		node vOrig = m_vOrig[v];
		if (vOrig)
			m_vCopy[vOrig] = nullptr;
	}
	clear();


	// create new component
	for(node v : G.nodes)
		getCopy(v);

	for(edge e : G.edges)
	{
		edge eCopy = newEdge(getCopy(e->source()),getCopy(e->target()));
		m_eOrig[eCopy] = e;
	}

	// expand vertices
	for(node v : nodes)
	{
		if (original(v) && v->indeg() >= 1 && v->outdeg() >= 1) {
			node vPrime = newNode();

			SListPure<edge> edges;
			v->outEdges(edges);

			SListConstIterator<edge> it;
			for(it = edges.begin(); it.valid(); ++it)
				moveSource(*it,vPrime);

			newEdge(v,vPrime);
		}
	}
}
Exemple #25
0
/*-----------------------------------------------------------------*/
static void 
addSuccessor (eBBlock * thisBlock, eBBlock * succ)
{
  /* check for boundary conditions */
  if (!thisBlock || !succ)
    return;

  /* add it to the succ of thisBlock */
  addSetIfnotP (&thisBlock->succList, succ);

  thisBlock->succVect =
    bitVectSetBit (thisBlock->succVect, succ->bbnum);
  /* add this edge to the list of edges */
  addSet (&graphEdges, newEdge (thisBlock, succ));

}
void addEdge(graph* g,int x,int y,int wt)
{
	edge* edj = newEdge(y,wt) ;
	if(g->adjlist[x]->firstedge == NULL)
	{
		g->adjlist[x]->firstedge = edj ;
	}
	else
	{
		edge* curedge = g->adjlist[x]->firstedge ;
		while(curedge->next != NULL)
			curedge = curedge->next ;
		curedge->next = edj ;
	}
	g->adjlist[x]->sz += 1 ;
}
Exemple #27
0
void VertexGraph::addEdge(int index1, int index2)
{
    // Vertex* v1 = findVertex(index1);
    // Vertex* v2 = findVertex(index2);

    Edge newEdge(findVertex(index1), findVertex(index2));

    for(int i = 0; i < vertices.size(); i++)
    {
        if(vertices[i].getIndex() == newEdge.getPreviousIndex())
        {   
            //found desired owner of edge
            vertices[i].addEdge(newEdge);
        }
    }
}
//
// insert an arc for each edge with direction m_arcDir
void CompactionConstraintGraphBase::insertBasicArcs(const PlanRep &PG)
{
	const Graph &G = *m_pOR;

	for(node v : G.nodes)
	{
		node start = m_pathNode[v];

		for(adjEntry adj : v->adjEdges) {
			if (m_pOR->direction(adj) == m_arcDir) {
				edge e = newEdge(start, m_pathNode[adj->theEdge()->opposite(v)]);
				m_edgeToBasicArc[adj] = e;

				m_cost[e] = m_edgeCost[PG.typeOf(adj->theEdge())];

				//try to pull nodes up in hierarchies
				if ( (PG.typeOf(adj->theEdge()) == Graph::generalization) &&
					(PG.typeOf(adj->theEdge()->target()) == Graph::generalizationExpander) &&
					!(PG.isExpansionEdge(adj->theEdge()))
					)
				{
					if (m_align)
					{
						//got to be higher than vertexarccost*doublebendfactor
						m_cost[e] = 4000*m_cost[e]; //use parameter later corresponding
						m_alignmentArc[e] = true;
					}//if align
					//to compconsgraph::doublebendfactor
					else m_cost[e] = 2*m_cost[e];
				}

				//set generalization type
				if (verticalGen(adj->theEdge())) m_verticalArc[e] = true;
				//set onborder
				if (PG.isDegreeExpansionEdge(adj->theEdge()))
				{
					edge borderE = adj->theEdge();
					node v1 = borderE->source();
					node v2 = borderE->target();
					m_border[e] = ((v1->degree()>2) && (v2->degree()>2) ? 2 : 1);
				}

			}
		}
	}
}
void addEdge(graph* g , int i , int y)
{
	edge* temp = g->adjlist[i]->firstedge ;
	edge* edg = newEdge(g->v[y]) ;
	if(temp == NULL)
	{
		g->adjlist[i]->firstedge = edg ; 
	}
	else
	{
		while(temp->next != NULL)
			temp = temp->next ;
		
		temp->next = edg ;
	}
	g->adjlist[i]->sz +=1 ;
}	
Exemple #30
0
static void reParent(struct phyloTree *tree)
{
if (tree->parent)
    {
    struct phyloTree *edge, *saveParent = tree->parent;

    reParent(saveParent); /* make the parent into the root */
    phyloDeleteEdge(saveParent, tree); /* remove this tree from the
					  parent tree */
    tree->parent = NULL; /* make this tree the root */
    edge = newEdge(tree, saveParent); /* add the old parent tree as a
					child of the new root */
    edge->parent = tree; /* set the parent in the new child */

    edge->ident->length = tree->ident->length;
    }
}