コード例 #1
0
ファイル: GraphX.cpp プロジェクト: ehab-abdelhamid/ScaleMine
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
ファイル: patternParser.cpp プロジェクト: ASabina/qreal
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
ファイル: patternParser.cpp プロジェクト: ZiminGrigory/qreal
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);
}