void triangle(Point3d a, Point3d b, Point3d c) { Point3d normal=prodVect(a,b,c); glNormal3d(normal.x,normal.y,normal.z); vertexColor(a.x,a.y,2*a.z); vertexColor(b.x,b.y,2*b.z); vertexColor(c.x,c.y,2*c.z); }
bool BicoloringAnalizer::isBipartite(int n) { int startVertex = 0; int currentColor = 0; std::queue<int> queueOfVertices; std::vector<bool> visited(n, false); std::vector<int> vertexColor(n, 1); queueOfVertices.push(startVertex); visited[startVertex] = true; vertexColor[startVertex] = currentColor; while (!queueOfVertices.empty()) { int currentVertex = queueOfVertices.front(); queueOfVertices.pop(); for (size_t i = 0; i < graph[currentVertex].size(); i++) { int adjacentVertex = graph[currentVertex][i]; if (!visited[adjacentVertex]) { visited[adjacentVertex] = true; vertexColor[adjacentVertex] = ~currentColor; queueOfVertices.push(adjacentVertex); } else { if (vertexColor[currentVertex] == vertexColor[adjacentVertex]) return false; } } currentColor = ~currentColor; } return true; }
/** Remove any vertices which can't be reached by traversing the graph forward * from start or in reverse from acceptEod. If \p renumber is false, no * vertex/edge renumbering is done. */ void pruneUseless(NGHolder &g, bool renumber) { DEBUG_PRINTF("pruning useless vertices\n"); assert(hasCorrectlyNumberedVertices(g)); vector<default_color_type> vertexColor(num_vertices(g)); bool work_done = pruneForwardUseless(g, g.g, g.start, vertexColor); work_done |= pruneForwardUseless( g, reverse_graph<NFAGraph, NFAGraph &>(g.g), g.acceptEod, vertexColor); if (!work_done) { return; } if (renumber) { g.renumberEdges(); g.renumberVertices(); } }