Пример #1
0
void insertIntoEdgeFreq(NodeX* src, int destNodeID, double destNodeLabel, double edgeLabel, tr1::unordered_map<string, void* >& edgeToFreq, bool addSrcOnly)
{
	string key;
	if(src->getLabel()>destNodeLabel)
	{
		stringstream sstmGF;
		if(src->getLabel()==destNodeLabel)
			sstmGF << src->getLabel()<<destNodeLabel<<","<<edgeLabel<<",";
		else
			sstmGF << src->getLabel()<<","<<destNodeLabel<<","<<edgeLabel<<",";
		key = sstmGF.str();
	}
	else
	{
		stringstream sstmGF;
		if(destNodeLabel==src->getLabel())
			sstmGF <<destNodeLabel<<src->getLabel()<<","<<edgeLabel<<",";
		else
			sstmGF <<destNodeLabel<<","<<src->getLabel()<<","<<edgeLabel<<",";
		key = sstmGF.str();
	}

	tr1::unordered_map<string, void* >::iterator iter = edgeToFreq.find(key);
	Pattern* pattern;
	if(iter==edgeToFreq.end())
	{
		GraphX* graph = new GraphX();
		NodeX* node1 = graph->AddNode(0, src->getLabel());
		NodeX* node2 = graph->AddNode(1, destNodeLabel);
		graph->addEdge(node1, node2, edgeLabel);
		pattern = new Pattern(graph);
		delete graph;

		edgeToFreq[key] = pattern;
	}
	else
	{
		pattern = (Pattern*)((*iter).second);
	}

	if(pattern->getGraph()->getNodeWithID(0)->getLabel()==src->getLabel())
	{
		pattern->addNode(src->getID(), 0);
		if(!addSrcOnly) pattern->addNode(destNodeID, 1);
	}
	else
	{
		pattern->addNode(src->getID(), 1);
		if(!addSrcOnly) pattern->addNode(destNodeID, 0);
	}
}
Пример #2
0
void PatternParser::parseNode(QDomElement const &node, Pattern &pattern)
{
	qreal const x = node.attribute("xPosition").toFloat();
	qreal const y = node.attribute("yPosition").toFloat();
	QString const parent = node.attribute("parent");
	QPointF const pos = QPointF(x, y);
	pattern.addNode(node.attribute("type"), node.attribute("name"), pos, parent);
}
Пример #3
0
void PatternParser::parseNode(const QDomElement &node, Pattern &pattern)
{
	const qreal x = node.attribute("xPosition").toFloat();
	const qreal y = node.attribute("yPosition").toFloat();
	const QString parent = node.attribute("parent");
	const QPointF pos = QPointF(x, y);
	pattern.addNode(node.attribute("type"), node.attribute("name"), pos, parent);
}