当前位置: 首页>>代码示例>>C++>>正文


C++ GraphAttributes::bends方法代码示例

本文整理汇总了C++中GraphAttributes::bends方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphAttributes::bends方法的具体用法?C++ GraphAttributes::bends怎么用?C++ GraphAttributes::bends使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GraphAttributes的用法示例。


在下文中一共展示了GraphAttributes::bends方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: revertUPR

void UPRSupplier::revertUPR(UpwardPlanRep& upr, GraphAttributes& uga){
	upr.delNode(getSource(upr));
	upr.delNode(getSink(upr));
	upr.delNode(getSink(upr));
	node source = getSource(upr);
	node sink = getSink(upr);
	
	vector<edge> edgesToDelete;
	edge e;
	forall_edges(e, upr){
		if (upr.original(e)->source() == upr.original(source) || upr.original(e)->target() == upr.original(sink))
			edgesToDelete.push_back(e);
	}

	for (vector<edge>::iterator it = edgesToDelete.begin(); it != edgesToDelete.end(); ++it){
		upr.delEdge(*it);
	}
	upr.delNode(source);
	upr.delNode(sink);
	
	vector<node> nodesToUnsplit;
	node n;
	forall_nodes(n, upr){
		if (n->indeg() == 1 && n->outdeg() == 1 && upr.isDummy(n)){
			nodesToUnsplit.push_back(n);
		}
	}
	
	for (vector<node>::iterator it = nodesToUnsplit.begin(); it != nodesToUnsplit.end(); ++it){
		edge in = (*it)->firstAdj()->theEdge();
		edge out = (*it)->lastAdj()->theEdge();
		if (in->source() == *it)
			swap(in, out);
		DPolyline& inBends = uga.bends(in);
		DPolyline& outBends = uga.bends(out);
		inBends.popBack();
		double x = inBends.back().m_x;
		int counter = 0;
		for (ListIterator<DPoint> it = outBends.begin(); it != outBends.end(); ++it){
			if (counter < 2){
				DPoint p(x, (*it).m_y);
				inBends.pushBack(p);
				counter++;
			} else {
				inBends.pushBack(*it);
			}
		}
		upr.unsplit(in, out);
	}
	
}
开发者ID:lparchaeology,项目名称:columnlayout,代码行数:51,代码来源:UPRSupplier.cpp

示例2: BendPromotion

void BendPromotion(Graph& G, GraphAttributes& GA) {
	List<edge> edges;
	G.allEdges(edges);

	while (!edges.empty()) {
		edge e = edges.popFrontRet();
		DPolyline bends_e = GA.bends(e);
		node s = e->source();
		node t = e->target();

		//check if an edge has bendpoints
		if (!bends_e.empty()) {
			while (!bends_e.empty()) {
				DPoint p = bends_e.front();

				//insert new node
				node n = G.newNode();
				GA.x(n) = p.m_x;
				GA.y(n) = p.m_y;

				edge e_ = G.newEdge(s, n);
				GA.arrowType(e_) = ogdf::EdgeArrow::None;
				GA.strokeColor(e_) = Color("#bababa");
				s = n;

				bends_e.popFront();
			}
			edge e_ = G.newEdge(s, t);
			GA.arrowType(e_) = ogdf::EdgeArrow::None;
			GA.strokeColor(e_) = Color("#bababa");

			G.delEdge(e);
		}
	}
}
开发者ID:bartvdput,项目名称:scriptie,代码行数:35,代码来源:scriptie.cpp

示例3: edgeLengths

	double LayoutStatistics::edgeLengths(
		const GraphAttributes &ga,
		double *pMinLength,
		double *pMaxLength,
		double *pAvgLength,
		double *pStdDeviation,
		bool    considerSelfLoops)
	{
		const Graph &G = ga.constGraph();
		int m = G.numberOfEdges();

		double totalLength = 0, minLength = numeric_limits<double>::max(), maxLength = -numeric_limits<double>::max();

		EdgeArray<double> len(G);
		int nSelfLoops = 0;

		for(edge e : G.edges) {
			if(!considerSelfLoops && e->isSelfLoop()) {
				nSelfLoops++;
				continue;
			}

			const DPolyline &dpl = ga.bends(e);

			if(!dpl.empty()) {
				len[e] = dpl.length();

			} else {
				DPoint pv = DPoint(ga.x(e->source()),ga.y(e->source()));
				DPoint pw = DPoint(ga.x(e->target()),ga.y(e->target()));
				len[e] = pv.distance(pw);
			}

			totalLength += len[e];
			minLength = min(minLength, len[e]);
			maxLength = max(maxLength, len[e]);
		}

		m -= nSelfLoops;

		double avgEdgeLength = totalLength / m;
		if(pAvgLength) *pAvgLength = avgEdgeLength;
		if(pMinLength) *pMinLength = minLength;
		if(pMaxLength) *pMaxLength = maxLength;

		if(pStdDeviation) {
			double sum = 0;
			for(edge e : G.edges) {
				if(!considerSelfLoops && e->isSelfLoop())
					continue;
				double d = len[e] - avgEdgeLength;
				sum += d*d;
			}

			*pStdDeviation = sqrt(sum / m);
		}

		return totalLength;
	}
开发者ID:marvin2k,项目名称:ogdf,代码行数:59,代码来源:LayoutStatistics.cpp

示例4: numberOfBends

	int LayoutStatistics::numberOfBends(
		const GraphAttributes &ga,
		int *pMinBendsPerEdge,
		int *pMaxBendsPerEdge,
		double *pAvgBendsPerEdge,
		double *pStdDeviation,
		bool    considerSelfLoops)
	{
		const Graph &G = ga.constGraph();
		int m = G.numberOfEdges();

		int totalBends = 0, minBends = numeric_limits<int>::max(), maxBends = 0;

		EdgeArray<int> bends(G);
		int nSelfLoops = 0;

		for(edge e : G.edges) {
			if(!considerSelfLoops && e->isSelfLoop()) {
				nSelfLoops++;
				continue;
			}

			const DPolyline &dpl = ga.bends(e);

			bends[e] = max(0, dpl.size() - 2);

			totalBends += bends[e];
			minBends = min(minBends, bends[e]);
			maxBends = max(maxBends, bends[e]);
		}

		m -= nSelfLoops;

		double avgBends = double(totalBends) / m;
		if(pAvgBendsPerEdge) *pAvgBendsPerEdge = avgBends;
		if(pMinBendsPerEdge) *pMinBendsPerEdge = minBends;
		if(pMaxBendsPerEdge) *pMaxBendsPerEdge = maxBends;

		if(pStdDeviation) {
			double sum = 0;
			for(edge e : G.edges) {
				if(!considerSelfLoops && e->isSelfLoop())
					continue;
				double d = bends[e] - avgBends;
				sum += d*d;
			}

			*pStdDeviation = sqrt(sum / m);
		}

		return totalBends;
	}
开发者ID:marvin2k,项目名称:ogdf,代码行数:52,代码来源:LayoutStatistics.cpp

示例5: call

void FastMultipoleEmbedder::call(GraphAttributes &GA, const EdgeArray<float>& edgeLength, const NodeArray<float>& nodeSize)
{
	allocate(GA.constGraph().numberOfNodes(), GA.constGraph().numberOfEdges());
	m_pGraph->readFrom(GA, edgeLength, nodeSize);
	run(m_numIterations);
	m_pGraph->writeTo(GA);
	deallocate();

	for(edge e : GA.constGraph().edges)
	{
		GA.bends(e).clear();
	}
}
开发者ID:ogdf,项目名称:ogdf,代码行数:13,代码来源:FastMultipoleEmbedder.cpp

示例6: writeAttributes

static inline void writeAttributes(
	std::ostream &out,
	const GraphAttributes &GA, const edge &e)
{
	const long flags = GA.attributes();

	out << "[";

	bool comma = false; // Whether to put comma before attribute.

	if(flags & GraphAttributes::edgeLabel) {
		writeAttribute(out, comma, "label", GA.label(e));
	}

	if(flags & GraphAttributes::edgeDoubleWeight) {
		writeAttribute(out, comma, "weight", GA.doubleWeight(e));
	} else if(flags & GraphAttributes::edgeIntWeight) {
		writeAttribute(out, comma, "weight", GA.intWeight(e));
	}

	if(flags & GraphAttributes::edgeGraphics) {
		// This should be legal cubic B-Spline in the future.
		std::stringstream sstream;
		for(const DPoint &p : GA.bends(e)) {
			sstream << p.m_x << "," << p.m_y << " ";
		}

		writeAttribute(out, comma, "pos", sstream.str());
	}

	if(flags & GraphAttributes::edgeArrow) {
		writeAttribute(out, comma, "dir", dot::toString(GA.arrowType(e)));
	}

	if(flags & GraphAttributes::edgeStyle) {
		writeAttribute(out, comma, "color", GA.strokeColor(e));
	}

	if(flags & GraphAttributes::edgeType) {
		writeAttribute(out, comma, "arrowhead", GA.arrowType(e));

		// Additionaly, according to IBM UML doc dependency is a dashed edge.
		if(GA.type(e) == Graph::dependency) {
			writeAttribute(out, comma, "style", "dashed");
		}
	}

	// NOTE: Edge subgraphs are not supported.

	out << "]";
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:51,代码来源:GraphIO_dot.cpp

示例7: mapGridLayout

void GridLayoutModule::mapGridLayout(const Graph &G,
	GridLayout &gridLayout,
	GraphAttributes &AG)
{
	// maximum width of columns and rows
	double maxWidth = 0;
	double yMax = 0;

	for(node v : G.nodes) {
		Math::updateMax<double>(maxWidth, AG.width(v));
		Math::updateMax<double>(maxWidth, AG.height(v));
		Math::updateMax<double>(yMax, gridLayout.y(v));
	}

	maxWidth += m_separation;

	// set position of nodes
	for(node v : G.nodes) {
		AG.x(v) = gridLayout.x(v) * maxWidth;
		AG.y(v) = (yMax - gridLayout.y(v)) * maxWidth;
	}

	// transform bend points of edges
	for(edge e : G.edges) {
		IPolyline ipl = gridLayout.polyline(e);

		// Remove superfluous bendpoints
		node v = e->source();
		while(!ipl.empty() && ipl.front() == IPoint(gridLayout.x(v), gridLayout.y(v))) {
			ipl.popFront();
		}
		v = e->target();
		while(!ipl.empty() && ipl.back() == IPoint(gridLayout.x(v), gridLayout.y(v))) {
			ipl.popBack();
		}

		DPolyline &dpl = AG.bends(e);
		dpl.clear();

		for (const IPoint &ip : ipl) {
			dpl.pushBack(DPoint(ip.m_x*maxWidth, (yMax-ip.m_y)*maxWidth));
		}

		dpl.normalize();
	}
}
开发者ID:ogdf,项目名称:ogdf,代码行数:46,代码来源:GridLayoutModule.cpp

示例8: CreateGraph

// create testGraph to test criteria imlementations
void CreateGraph(Graph& G, GraphAttributes& GA) {
	// add nodes
	node zero = G.newNode();
	node one = G.newNode();
	node two = G.newNode();
	node three = G.newNode();
	node four = G.newNode();

	// set node positions
	GA.x(zero) = 4 * NODE_WIDTH;
	GA.y(zero) = 0;

	GA.x(one) = 4 * NODE_WIDTH;
	GA.y(one) = 4 * NODE_HEIGHT;

	GA.x(two) = 0;
	GA.y(two) = 2 * NODE_HEIGHT;

	GA.x(three) = 4 * NODE_WIDTH;
	GA.y(three) = 8 * NODE_HEIGHT;

	GA.x(four) = 0;
	GA.y(four) = 8 * NODE_HEIGHT;

	// add edges
	edge zero_one = G.newEdge(zero, one);
	edge zero_three = G.newEdge(zero, three);
	edge zero_four = G.newEdge(zero, four);
	edge one_two = G.newEdge(one, two);
	edge one_three = G.newEdge(one, three);
	edge two_three = G.newEdge(two, three);

	DPolyline &p = GA.bends(zero_three);
	p.pushBack(DPoint(6 * NODE_WIDTH, 2 * NODE_HEIGHT));
	p.pushBack(DPoint(6 * NODE_WIDTH, 6 * NODE_HEIGHT));
}
开发者ID:bartvdput,项目名称:scriptie,代码行数:37,代码来源:scriptie.cpp

示例9: write_ogml_layout_nodes_edges


//.........这里部分代码省略.........
				os << "\" width=\"" << A.width(v) << "\" height=\"" << A.height(v) << "\" />\n";
			}

			if(A.has(GraphAttributes::nodeStyle)) {
				// fill-tag
				GraphIO::indent(os,5) << "<fill";

				// color-attribute of fill-tag
				os << " color=\"" << A.fillColor(v) << "\"";

				// pattern- and patternColor-attribute of fill-tag (closing)
				os << " pattern=\"" << fillPatternToOGML(A.fillPattern(v)) << "\" patternColor=\"" << A.fillBgColor(v) << "\" />\n";
				// line-tag
				GraphIO::indent(os,5) << "<line type=\"" << edgeStyleToOGML(A.strokeType(v)) <<  "\" width=\"" << A.strokeWidth(v) << "\""
					<< " color=\"" << A.strokeColor(v) << "\"";

				// closing fill-tag
				os << " />\n";
			}

			GraphIO::indent(os,4) << "</nodeStyle>\n";
		}
	}

	if (A.has(GraphAttributes::edgeGraphics | GraphAttributes::edgeStyle))
	{
		int pointId = 0;

		for(edge e : G.edges) {
			GraphIO::indent(os,4) << "<edgeStyle idRef=\"e" << e->index() << "\">\n";

			if(A.has(GraphAttributes::edgeStyle)) {
				GraphIO::indent(os,5) << "<line ";
				if (A.has(GraphAttributes::edgeStyle)) {
					os << "type=\"" << edgeStyleToOGML(A.strokeType(e)) << "\" width=\"" << A.strokeWidth(e) << "\" ";
					os << "color=\"" << A.strokeColor(e) << "\" />\n";
				} else 	{
					os << " />\n";
				}
			}

			// TODO review the handling of edge arrows
			if(A.has(GraphAttributes::edgeArrow))
			{
				switch(A.arrowType(e)) {
				case eaNone:
					GraphIO::indent(os,5) << "<sourceStyle type=\"none\" color=\"#000000\" size=\"1\" />\n";
					GraphIO::indent(os,5) << "<targetStyle type=\"none\" color=\"#000000\" size=\"1\" />\n";
					break;
				case eaLast:
					GraphIO::indent(os,5) << "<sourceStyle type=\"none\" color=\"#000000\" size=\"1\" />\n";
					GraphIO::indent(os,5) << "<targetStyle type=\"arrow\" color=\"#000000\" size=\"1\" />\n";
					break;
				case eaFirst:
					GraphIO::indent(os,5) << "<sourceStyle type=\"arrow\" color=\"#000000\" size=\"1\" />\n";
					GraphIO::indent(os,5) << "<targetStyle type=\"none\" color=\"#000000\" size=\"1\" />\n";
					break;
				case eaBoth:
					GraphIO::indent(os,5) << "<sourceStyle type=\"arrow\" color=\"#000000\" size=\"1\" />\n";
					GraphIO::indent(os,5) << "<targetStyle type=\"arrow\" color=\"#000000\" size=\"1\" />\n";
					break;
				case eaUndefined:
					// do nothing
					break;
				default:
					// do nothing
					break;
				}
			}

			// handling of points
			// TODO: Revise for new OGML specification
			const DPolyline &dpl = A.bends(e);
			if (!dpl.empty()) {
				// handle source
				node v = e->source();
				if(dpl.front().m_x < A.x(v) - A.width(v)/2 ||
					dpl.front().m_x > A.x(v) + A.width(v)/2 ||
					dpl.front().m_y < A.y(v) - A.height(v)/2 ||
					dpl.front().m_y > A.y(v) + A.height(v)/2)	{
						GraphIO::indent(os,5) << "<point id=\"p" << pointId++ << "\" x=\"" << A.x(e->source()) << "\" y=\"" << A.y(e->source()) << "\" />\n";
				}
				// handle points
				for(const DPoint &dp : dpl) {
					GraphIO::indent(os,5) << "<point id=\"p" << pointId++ << "\" x=\"" << dp.m_x << "\" y=\"" << dp.m_y << "\" />\n";
				}
				// handle target
				v = e->target();
				if(dpl.back().m_x < A.x(v) - A.width(v)/2 ||
					dpl.back().m_x > A.x(v) + A.width(v)/2 ||
					dpl.back().m_y < A.y(v) - A.height(v)/2 ||
					dpl.back().m_y > A.y(v) + A.height(v)/2) {
						GraphIO::indent(os,5) << "<point id=\"p" << pointId++ << "\" x=\"" << A.x(e->target()) << "\" y=\"" << A.y(e->target()) << "\" />\n";
				}
			}

			GraphIO::indent(os,4) << "</edgeStyle>\n";
		}
	}
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:101,代码来源:GraphIO_ogml.cpp

示例10: assignCoordinates

void EdgeLengthCompacter::assignCoordinates(const Graph& g, NodeArray<int>& nodeColumns, EdgeArray<int>& edgeColumns, NodeArray<NodeCoordinates>& nodeCoordinates, EdgeArray<EdgeCoordinates>& edgeCoordinates, GraphAttributes& retVal){
	assignXCoordinates(nodeColumns, retVal);

	node n;
	forall_nodes(n, g){
		retVal.y(n) = (nodeCoordinates[n].y_top + nodeCoordinates[n].y_bottom) / 2;
	}
	
	edge e;
	forall_edges(e, g){
		EdgeCoordinates& ec = edgeCoordinates[e];
		
//		cout << "Edge "<< e->source() << " -> " << e->target() << endl;
//		cout << "\ty1\t"<< ec.y_1<< endl;
//		cout << "\ty2\t"<< ec.y_2<< endl;
//		cout << "\tt off\t"<< ec.x_offset_target<< endl;
//		cout << "\ts_off\t"<< ec.x_offset_source<< endl;
		
		node source = e->source();
		node target = e->target();
		
		double sourceColumn = nodeColumns[source];
		double edgeColumn = edgeColumns[e];
		double targetColumn = nodeColumns[target];
		
		double sourceX = sourceColumn * (boxWidth + boxBoxSpacing) + ec.x_offset_source;
		double targetX = targetColumn * (boxWidth + boxBoxSpacing) + ec.x_offset_target;
		double edgeX = edgeColumns[e] * (boxWidth + boxBoxSpacing);
		
		retVal.bends(e).clear();

		DPoint p0(sourceX, nodeCoordinates[source].y_bottom + 0.001);
		retVal.bends(e).pushBack(p0);

		DPoint p1(sourceX, ec.y_1);
		retVal.bends(e).pushBack(p1);

		if (sourceColumn == edgeColumns[e]){
			DPoint p2(sourceX, ec.y_1);	
			retVal.bends(e).pushBack(p2);

			DPoint p3(sourceX, ec.y_2);
			retVal.bends(e).pushBack(p3);
		} else if (targetColumn == edgeColumns[e]){
			DPoint p2(targetX, ec.y_1);	
			retVal.bends(e).pushBack(p2);

			DPoint p3(targetX, ec.y_2);			
			retVal.bends(e).pushBack(p3);
		} else {
			DPoint p2(edgeX, ec.y_1);	
			retVal.bends(e).pushBack(p2);

			DPoint p3(edgeX, ec.y_2);			
			retVal.bends(e).pushBack(p3);
		}
			
		DPoint p4(targetX, ec.y_2);	
		retVal.bends(e).pushBack(p4);

		DPoint p5(targetX, nodeCoordinates[target].y_top - 0.001);
		retVal.bends(e).pushBack(p5);
	}
开发者ID:lparchaeology,项目名称:columnlayout,代码行数:63,代码来源:EdgeLengthCompacter.cpp

示例11: getBasicGraphAttributes

//*************************************************************
// returns GraphAttributes associated with basic graph i
//
void SimDraw::getBasicGraphAttributes(int i, GraphAttributes &GA, Graph &G)
{
    G = m_G;
    GA.init(G,m_GA.attributes());
    
    List<edge> LE;
    m_G.allEdges(LE);
    forall_listiterators(edge,it,LE)
	if(m_GA.inSubGraph(*it,i))
	{
	    node v;
	    forall_nodes(v,G)
	    {
		if(compare(GA,v,m_GA,(*it)->source()))
		{
		    if(m_GA.attributes() & GraphAttributes::nodeGraphics)
		    {
			GA.x(v) = m_GA.x((*it)->source());
			GA.y(v) = m_GA.y((*it)->source());
			GA.height(v) = m_GA.height((*it)->source());
			GA.width(v) = m_GA.width((*it)->source());
		    }
				
		    if(m_GA.attributes() & GraphAttributes::nodeId)
			GA.idNode(v) = m_GA.idNode((*it)->source());
		    
		    if(m_GA.attributes() & GraphAttributes::nodeLabel)
			GA.labelNode(v) = m_GA.labelNode((*it)->source());
		}
			
		if(compare(GA,v,m_GA,(*it)->target()))
		{
		    if(m_GA.attributes() & GraphAttributes::nodeGraphics)
		    {
			GA.x(v) = m_GA.x((*it)->target());
			GA.y(v) = m_GA.y((*it)->target());
			GA.height(v) = m_GA.height((*it)->target());
			GA.width(v) = m_GA.width((*it)->target());
		    }
				
		    if(m_GA.attributes() & GraphAttributes::nodeId)
			GA.idNode(v) = m_GA.idNode((*it)->target());
		    
		    if(m_GA.attributes() & GraphAttributes::nodeLabel)
			GA.labelNode(v) = m_GA.labelNode((*it)->target());
		}
	    }
	    
	    edge e;
	    forall_edges(e,G)
	    {
		if(compare(GA,e->source(),m_GA,(*it)->source())
		&& compare(GA,e->target(),m_GA,(*it)->target()))
		{
		    if(m_GA.attributes() & GraphAttributes::edgeIntWeight)
			GA.intWeight(e) = m_GA.intWeight(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeLabel)
			GA.labelEdge(e) = m_GA.labelEdge(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeColor)
			GA.colorEdge(e) = m_GA.colorEdge(*it);
		    
		    if(m_GA.attributes() & GraphAttributes::edgeGraphics)
			GA.bends(e) = m_GA.bends(*it);
		}
	    }
	}
开发者ID:,项目名称:,代码行数:71,代码来源:

示例12: read

bool GmlParser::read(Graph &G, GraphAttributes &AG)
{
	OGDF_ASSERT(&G == &(AG.constGraph()))

	G.clear();

	int minId = m_mapToNode.low();
	int maxId = m_mapToNode.high();
	int notDefined = minId-1; //indicates not defined id key

	HashArray<string,Shape> strToShape(shRect);
	strToShape["rectangle"]        = shRect;
	strToShape["rect"]             = shRect;
	strToShape["roundedRect"]      = shRoundedRect;
	strToShape["oval"]             = shEllipse;
	strToShape["ellipse"]          = shEllipse;
	strToShape["triangle"]         = shTriangle;
	strToShape["pentagon"]         = shPentagon;
	strToShape["hexagon"]          = shHexagon;
	strToShape["octagon"]          = shOctagon;
	strToShape["rhomb"]            = shRhomb;
	strToShape["trapeze"]          = shTrapeze;
	strToShape["parallelogram"]    = shParallelogram;
	strToShape["invTriangle"]      = shInvTriangle;
	strToShape["invTrapeze"]       = shInvTrapeze;
	strToShape["invParallelogram"] = shInvParallelogram;
	strToShape["image"]            = shImage;

	DPolyline bends;

	GmlObject *son = m_graphObject->m_pFirstSon;
	for(; son; son = son->m_pBrother) {

		switch(id(son)) {
		case nodePredefKey: {
			if (son->m_valueType != gmlListBegin) break;

			// set attributes to default values
			int vId = notDefined;
			double x = 0, y = 0, w = 0, h = 0;
			string label;
			string templ;
			string fill;  // the fill color attribute
			string line;  // the line color attribute
			string shape; //the shape type
			float lineWidth = 1.0f; //node line width
			int pattern = 1; //node brush pattern
			int stipple = 1; //line style pattern
			int weight = 0; // node weight

			// read all relevant attributes
			GmlObject *nodeSon = son->m_pFirstSon;
			for(; nodeSon; nodeSon = nodeSon->m_pBrother) {
				switch(id(nodeSon)) {
				case idPredefKey:
					if(nodeSon->m_valueType != gmlIntValue) break;
					vId = nodeSon->m_intValue;
					break;

				case graphicsPredefKey: {
					if (nodeSon->m_valueType != gmlListBegin) break;

					GmlObject *graphicsObject = nodeSon->m_pFirstSon;
					for(; graphicsObject;
						graphicsObject = graphicsObject->m_pBrother)
					{
						switch(id(graphicsObject)) {
						case xPredefKey:
							if(graphicsObject->m_valueType != gmlDoubleValue) break;
							x = graphicsObject->m_doubleValue;
							break;

						case yPredefKey:
							if(graphicsObject->m_valueType != gmlDoubleValue) break;
							y = graphicsObject->m_doubleValue;
							break;

						case wPredefKey:
							if(graphicsObject->m_valueType != gmlDoubleValue) break;
							w = graphicsObject->m_doubleValue;
							break;

						case hPredefKey:
							if(graphicsObject->m_valueType != gmlDoubleValue) break;
							h = graphicsObject->m_doubleValue;
							break;

						case fillPredefKey:
							if(graphicsObject->m_valueType != gmlStringValue) break;
							fill = graphicsObject->m_stringValue;
							break;

						case linePredefKey:
							if(graphicsObject->m_valueType != gmlStringValue) break;
							line = graphicsObject->m_stringValue;
							break;

						case lineWidthPredefKey:
							if(graphicsObject->m_valueType != gmlDoubleValue) break;
							lineWidth = (float)graphicsObject->m_doubleValue;
//.........这里部分代码省略.........
开发者ID:lncosie,项目名称:ogdf,代码行数:101,代码来源:GmlParser.cpp

示例13: getBasicGraphAttributes

//*************************************************************
// returns GraphAttributes associated with basic graph i
//
void SimDraw::getBasicGraphAttributes(int i, GraphAttributes &GA, Graph &G)
{
	G = m_G;
	GA.init(G,m_GA.attributes());

	List<edge> LE;
	m_G.allEdges(LE);
	for(edge eLE : LE)
		if(m_GA.inSubGraph(eLE,i))
		{
			for(node v : G.nodes)
			{
				if(compare(GA,v,m_GA,eLE->source()))
				{
					if(m_GA.attributes() & GraphAttributes::nodeGraphics)
					{
						GA.x(v) = m_GA.x(eLE->source());
						GA.y(v) = m_GA.y(eLE->source());
						GA.height(v) = m_GA.height(eLE->source());
						GA.width(v) = m_GA.width(eLE->source());
					}

					if(m_GA.attributes() & GraphAttributes::nodeId)
						GA.idNode(v) = m_GA.idNode(eLE->source());

					if(m_GA.attributes() & GraphAttributes::nodeLabel)
						GA.label(v) = m_GA.label(eLE->source());
				}

				if(compare(GA,v,m_GA,eLE->target()))
				{
					if(m_GA.attributes() & GraphAttributes::nodeGraphics)
					{
						GA.x(v) = m_GA.x(eLE->target());
						GA.y(v) = m_GA.y(eLE->target());
						GA.height(v) = m_GA.height(eLE->target());
						GA.width(v) = m_GA.width(eLE->target());
					}

					if(m_GA.attributes() & GraphAttributes::nodeId)
						GA.idNode(v) = m_GA.idNode(eLE->target());

					if(m_GA.attributes() & GraphAttributes::nodeLabel)
						GA.label(v) = m_GA.label(eLE->target());
				}
			}

			for(edge e : G.edges)
			{
				if(compare(GA,e->source(),m_GA,eLE->source())
					&& compare(GA,e->target(),m_GA,eLE->target()))
				{
					if(m_GA.attributes() & GraphAttributes::edgeIntWeight)
						GA.intWeight(e) = m_GA.intWeight(eLE);

					if(m_GA.attributes() & GraphAttributes::edgeLabel)
						GA.label(e) = m_GA.label(eLE);

					if(m_GA.attributes() & GraphAttributes::edgeStyle)
						GA.strokeColor(e) = m_GA.strokeColor(eLE);

					if(m_GA.attributes() & GraphAttributes::edgeGraphics)
						GA.bends(e) = m_GA.bends(eLE);
				}
			}
		}
		else
		{
			List<edge> LE2;
			G.allEdges(LE2);
			for(edge e2 : LE2)
			{
				if(compare(GA,e2->source(),m_GA,eLE->source())
					&& compare(GA,e2->target(),m_GA,eLE->target()))
				{
					G.delEdge(e2);
				}
			}
		}

		//remove all Nodes with degree == 0
		//this can change the IDs of the nodes in G.
		List<node> LN;
		G.allNodes(LN);
		for(node v : LN)
			if(v->degree() == 0)
				G.delNode(v);

}//end getBasicGraphAttributes
开发者ID:lncosie,项目名称:ogdf,代码行数:92,代码来源:SimDraw.cpp

示例14: angularResolution

	double LayoutStatistics::angularResolution(
		const GraphAttributes &ga,
		double *pMaxAngle,
		double *pAvgAngle,
		double *pStdDeviation,
		bool    considerBends)
	{
		const Graph &G = ga.constGraph();

		double minAngle = 2*Math::pi, maxAngle = 0, sumAngles = 0;

		int numAngles = 0;
		ListPure<double> allAngles;

		for (node v : G.nodes) {

			double vx = ga.x(v), vy = ga.y(v);

			List<double> angles;
			for (adjEntry adj : v->adjEntries) {
				const DPolyline &dpl = ga.bends(adj->theEdge());
				double ex, ey;
				if (dpl.empty()) {
					ex = ga.x(adj->twinNode());
					ey = ga.y(adj->twinNode());
				}
				else {
					ex = dpl.front().m_x;
					ey = dpl.front().m_y;
				}

				angles.pushBack(atan2(ex-vx, ey-vy));
			}

			if (angles.size() < 2)
				continue;

			numAngles += angles.size();
			angles.quicksort();

			double lastAngle = angles.back();
			for (double psi : angles) {
				double alpha = psi - lastAngle;
				if (pStdDeviation)
					allAngles.pushBack(alpha);

				sumAngles += alpha;
				minAngle = min(minAngle, alpha);
				maxAngle = max(maxAngle, alpha);

				lastAngle = psi;
			}
		}

		if (considerBends) {
			for (edge e : G.edges) {
				DPolyline dpl = ga.bends(e);

				dpl.pushFront( DPoint(ga.x(e->source()), ga.y(e->source())) );
				dpl.pushBack ( DPoint(ga.x(e->target()), ga.y(e->target())) );
				dpl.normalize();

				if (dpl.size() < 3)
					continue;

				for (ListConstIterator<DPoint> it = dpl.begin().succ(); it != dpl.rbegin(); ++it) {
					double bx = (*it).m_x, by = (*it).m_y;

					const DPoint &p1 = *it.pred();
					double psi1 = atan2(p1.m_x-bx, p1.m_y-by);

					const DPoint &p2 = *it.succ();
					double psi2 = atan2(p2.m_x - bx, p2.m_y - by);

					double alpha = fabs(psi1 - psi2);
					if (alpha > Math::pi)
						alpha -= Math::pi;

					sumAngles += 2 * Math::pi;
					minAngle = min(minAngle, alpha);
					maxAngle = max(maxAngle, alpha + Math::pi);

					if (pStdDeviation) {
						numAngles += 2;
						allAngles.pushBack(alpha);
						allAngles.pushBack(alpha*Math::pi);
					}
				}
			}
		}

		double avgAngle = sumAngles / numAngles;
		if (pAvgAngle) *pAvgAngle = avgAngle;
		if (pMaxAngle) *pMaxAngle = maxAngle;

		if (pStdDeviation) {
			double sum = 0;
			for (double alpha : allAngles) {
				double d = alpha - avgAngle;
				sum += d*d;
//.........这里部分代码省略.........
开发者ID:marvin2k,项目名称:ogdf,代码行数:101,代码来源:LayoutStatistics.cpp

示例15: layout

void VisibilityLayout::layout(GraphAttributes &GA, const UpwardPlanRep &UPROrig)
{
	UpwardPlanRep UPR = UPROrig;

	//clear some data
	for(edge e : GA.constGraph().edges) {
		GA.bends(e).clear();
	}

	int minGridDist = 1;
	for(node v : GA.constGraph().nodes) {
		if (minGridDist < max(GA.height(v), GA.width(v)))
			minGridDist = (int) max(GA.height(v), GA.width(v));
	}
	minGridDist = max(minGridDist*2+1, m_grid_dist);

	CombinatorialEmbedding &gamma = UPR.getEmbedding();
	//add edge (s,t)
	adjEntry adjSrc = nullptr;
	for(adjEntry adj : UPR.getSuperSource()->adjEntries) {
		if (gamma.rightFace(adj) == gamma.externalFace())
			adjSrc = adj;
			break;
	}

	OGDF_ASSERT(adjSrc != nullptr);

	edge e_st = UPR.newEdge(adjSrc, UPR.getSuperSink()); // on the right
	gamma.computeFaces();
	gamma.setExternalFace(gamma.rightFace(e_st->adjSource()));

	constructVisibilityRepresentation(UPR);

	// the preliminary postion
	NodeArray<int> xPos(UPR);
	NodeArray<int> yPos(UPR);

	// node Position
	for(node v : UPR.nodes) {
		NodeSegment vVis = nodeToVis[v];
		int x = (int) (vVis.x_l + vVis.x_r)/2 ; // median positioning
		xPos[v] = x;
		yPos[v] = vVis.y;

		if (UPR.original(v) != nullptr) {
			node vOrig = UPR.original(v);
			//final position
			GA.x(vOrig) = x * minGridDist;
			GA.y(vOrig)	= vVis.y * minGridDist;
		}
	}

	//compute bendpoints
	for(edge e : GA.constGraph().edges) {
		const List<edge> &chain = UPR.chain(e);
		for(edge eUPR : chain) {
			EdgeSegment eVis = edgeToVis[eUPR];
			if (chain.size() == 1) {
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) > 1) {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
				}
			}
			else {
				//short edge
				if ((yPos[eUPR->target()] - yPos[eUPR->source()]) == 1) {
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
				//long edge
				else {
					DPoint p1(eVis.x*minGridDist, (yPos[eUPR->source()]+1)*minGridDist);
					DPoint p2(eVis.x*minGridDist, (yPos[eUPR->target()]-1)*minGridDist);
					GA.bends(e).pushBack(p1);
					if (yPos[eUPR->source()]+1 != yPos[eUPR->target()]-1)
						GA.bends(e).pushBack(p2);
					if (UPR.original(eUPR->target()) == nullptr) {
						node tgtUPR = eUPR->target();
						DPoint p(xPos[tgtUPR]*minGridDist, yPos[tgtUPR]*minGridDist);
						GA.bends(e).pushBack(p);
					}
				}
			}
		}

		DPolyline &poly = GA.bends(e);
		DPoint pSrc(GA.x(e->source()), GA.y(e->source()));
		DPoint pTgt(GA.x(e->target()), GA.y(e->target()));
		poly.normalize(pSrc, pTgt);
	}
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:97,代码来源:VisibilityLayout.cpp


注:本文中的GraphAttributes::bends方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。