示例#1
0
文件: dot.cpp 项目: jxxsoft/hypercube
void DotGraphInput::edge(idSet &src, edgeSet &edges)
{
	idSet dst;
	Attributes attr;
	Vertex *v;
	Edge *e;

	nextToken();

	switch (_token) {
		case ID:
			v = addVertex(_id);
			setVertexAttributes(v, _nodeAttributes);
			dst.insert(_id);
			nodeId();
			break;
		case SUBGRAPH:
		case LBRC:
			subgraph(dst);
			break;
		default:
			error();
			return;
	}

	for (idSet::iterator i = src.begin(); i != src.end(); i++) {
		for (idSet::iterator j = dst.begin(); j != dst.end(); j++) {
			if (*i == *j) {
				error();
				return;
			}
			e = addEdge(*i, *j);
			setEdgeAttributes(e, _edgeAttributes);
			edges.insert(e);
		}
	}

	if (_token == EDGEOP)
		edge(dst, edges);
	if (_token == LBRK)
		attributeList(attr);

	for (edgeSet::iterator i = edges.begin(); i != edges.end(); i++)
		setEdgeAttributes(*i, attr);
}
示例#2
0
文件: Delaunay.cpp 项目: apqw/epi
void Delaunay::HandleEdge(const vertex * p0, const vertex * p1, edgeSet& edges)
{
	const vertex * pV0(NULL);
	const vertex * pV1(NULL);

	if (* p0 < * p1)
	{
		pV0 = p0;
		pV1 = p1;
	}
	else
	{
		pV0 = p1;
		pV1 = p0;
	}

	// Insert a normalized edge. If it's already in edges, insertion will fail,
	// thus leaving only unique edges.
	edges.insert(edge(pV0, pV1));
}