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


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

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


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

示例1: readColor

static inline bool readVizAttribute(
	GraphAttributes &GA,
	edge e,
	const pugi::xml_node tag)
{
	const long attrs = GA.attributes();

	if(string(tag.name()) == "viz:color") {
		if(attrs & GraphAttributes::edgeStyle) {
			return readColor(GA.strokeColor(e), tag);
		}
	} else if(string(tag.name()) == "viz:thickness") {
		auto thickAttr = tag.attribute("value");
		if(!thickAttr) {
			GraphIO::logger.lout() << "Missing \"value\" on thickness tag." << std::endl;
			return false;
		}

		if(attrs & GraphAttributes::edgeDoubleWeight) {
			GA.doubleWeight(e) = thickAttr.as_double();
		} else if(attrs & GraphAttributes::edgeIntWeight) {
			GA.intWeight(e) = thickAttr.as_int();
		}
	} else if(string(tag.name()) == "viz:shape") {
		// Values: solid, dotted, dashed, double. Not supported in OGDF.
	} else {
		GraphIO::logger.lout() << "Incorrect tag \"" << tag.name() << "\"." << std::endl;
		return false;
	}

	return true;
}
开发者ID:ogdf,项目名称:ogdf,代码行数:32,代码来源:GexfParser.cpp

示例2: writeAttributes

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

	if(attrs & GraphAttributes::edgeStyle) {
		const Color &color = GA.strokeColor(e);

		const int red = color.red();
		const int green = color.green();
		const int blue = color.blue();
		const int alpha = color.alpha();

		GraphIO::indent(out, depth) << "<viz:color "
		                            << "red=\"" << red << "\" "
		                            << "green=\"" << green << "\" "
		                            << "blue=\"" << blue << "\" "
		                            << "alpha=\"" << alpha << "\" "
		                            << "/>\n";
	}

	if(attrs & GraphAttributes::edgeDoubleWeight) {
		const double weight = GA.doubleWeight(e);
		GraphIO::indent(out, depth) << "<viz:thickness "
		                            << "value=\"" << weight << "\" "
		                            << "/>\n";
	} else if(attrs & GraphAttributes::edgeIntWeight) {
		const int weight = GA.intWeight(e);
		GraphIO::indent(out, depth) << "<viz:thickness "
		                            << "value=\"" << weight << "\" "
		                            << "/>\n";
	}

	/*
	 * Edge type and arrow are not supported by VIZ module. Therefore, they
	 * need to be written using <attvalues> tag (for estetic reasons, we write
	 * them only if either of them is present). For convenience reasons, we use
	 * the same names and values as in GraphML format.
	 */
	if(!(attrs & (GraphAttributes::edgeType | GraphAttributes::edgeArrow))) {
		return;
	}

	GraphIO::indent(out, depth) << "<attvalues>\n";

	if(attrs & GraphAttributes::edgeType) {
		writeAttValue(
			out, depth + 1,
			graphml::a_edgeType, graphml::toString(GA.type(e)));
	}
	if(attrs & GraphAttributes::edgeArrow) {
		writeAttValue(
			out, depth + 1,
			graphml::a_edgeArrow, graphml::toString(GA.arrowType(e)));
	}

	GraphIO::indent(out, depth) << "</attvalues>\n";
}
开发者ID:lncosie,项目名称:ogdf,代码行数:59,代码来源:GraphIO_gexf.cpp

示例3: 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

示例4: readData

bool GraphMLParser::readData(
	GraphAttributes &GA,
	const edge &e,
	const pugi::xml_node edgeData)
{
	pugi::xml_attribute keyId = edgeData.attribute("key");
	if (!keyId) {
		GraphIO::logger.lout() << "Edge data does not have a key." << endl;
		return false;
	}

	const long attrs = GA.attributes();
	pugi::xml_text text = edgeData.text();

	switch(graphml::toAttribute(m_attrName[keyId.value()])) {
	case graphml::a_edgeLabel:
		if(attrs & GraphAttributes::edgeLabel) {
			GA.label(e) = text.get();
		}
		break;
	case graphml::a_edgeWeight:
		if(attrs & GraphAttributes::edgeIntWeight) {
			GA.intWeight(e) = text.as_int();
		} else if(attrs & GraphAttributes::edgeDoubleWeight) {
			GA.doubleWeight(e) = text.as_double();
		}
		break;
	case graphml::a_edgeType:
		if(attrs & GraphAttributes::edgeType) {
			GA.type(e) = graphml::toEdgeType(text.get());
		}
		break;
	case graphml::a_edgeArrow:
		if(attrs & GraphAttributes::edgeArrow) {
			GA.arrowType(e) = graphml::toArrow(text.get());
		}
		break;
	case graphml::a_edgeStroke:
		if(attrs & GraphAttributes::edgeStyle) {
			GA.strokeColor(e) = text.get();
		}
		break;
	default:
		GraphIO::logger.lout(Logger::LL_MINOR) << "Unknown edge attribute with \""
		             << keyId.value()
		             << "\"." << endl;
	}

	return true;
}
开发者ID:marvin2k,项目名称:ogdf,代码行数:50,代码来源:GraphMLParser.cpp

示例5: 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,代码来源:

示例6: 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


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