本文整理汇总了C++中Vertices::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ Vertices::begin方法的具体用法?C++ Vertices::begin怎么用?C++ Vertices::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vertices
的用法示例。
在下文中一共展示了Vertices::begin方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isConnected
bool Graph::isConnected ()
{
int reachedsize = 0;
for (int v = 0; v < size; v++) { reachedVertices[v] = false; }
std::list<int> *nextVertices = new std::list<int>();
nextVertices->push_back(0);
reachedVertices[0] = true;
reachedsize++;
while (!nextVertices->empty())
{
int currentVertex = nextVertices->front();
nextVertices->pop_front();
Vertices *adjList = adjacencySets[currentVertex];
for (Vertices::iterator it = adjList->begin(); it != adjList->end(); ++it) {
int adjVertex = *it;
if (!reachedVertices[adjVertex]) {
nextVertices->push_back(adjVertex);
reachedVertices[adjVertex] = true;
reachedsize++;
}
}
}
delete nextVertices;
return reachedsize == size;
}
示例2: operatorSinternal
void operatorSinternal(const Mesh& m, Matrix& mat, const Vertices& points, const double& coeff)
{
std::cout << "INTERNAL OPERATOR S..." << std::endl;
for ( Vertices::const_iterator vit = points.begin(); vit != points.end(); ++vit) {
for ( Mesh::const_iterator tit = m.begin(); tit != m.end(); ++tit) {
mat(vit->index(), tit->index()) = _operatorSinternal(*tit, *vit) * coeff;
}
}
}
示例3: dijkstra
static void dijkstra(Graph& g, Vertex s, Vertices& p, Reals& d) {
dijkstra_shortest_paths(
g,
s,
weight_map(get(&EdgeProperty::weight, g)).
predecessor_map(make_iterator_property_map(p.begin(), get(vertex_index, g))).
distance_map(make_iterator_property_map(d.begin(), get(vertex_index, g)))
);
}
示例4: Vertices
Vertices *Graph::getAdjacentVertices (int v, int vMax)
{
if (vMax == -1) { vMax = v; }
Vertices *adjVertices = new Vertices();
Vertices *adjSet = adjacencySets[v];
for (Vertices::iterator it = adjSet->begin(); it != adjSet->end(); ++it)
{
int adjV = *it;
if (adjV < vMax) { adjVertices->insert(adjV); }
}
return adjVertices;
}
示例5: insert
/** Insert a function into a vertex of the forest, or create a new vertex. The (new) vertex into which the function was
* inserted is either a child of @p parent or a root node. The @p outputs are used to select the vertex into which the
* function is inserted (all functions of a particular vertex produced the same output when run with the same input). */
void insert(SgAsmFunction *func, OutputValues outputs, PartitionForest::Vertex *parent) {
Vertices candidates = parent ? parent->children : vertices_at_level(0);
assert(!contains(candidates, func));
for (Vertices::iterator vi=candidates.begin(); vi!=candidates.end(); ++vi) {
Vertex *vertex = *vi;
if (outputs.size()==vertex->outputs.size() && std::equal(outputs.begin(), outputs.end(), vertex->outputs.begin())) {
vertex->functions.insert(func);
return;
}
}
size_t lno = parent ? parent->get_level() + 1 : 0;
assert(lno<levels.size());
levels[lno].vertices.insert(new Vertex(parent, func, outputs));
}
示例6: buildDataStructure
void Graph::buildDataStructure ()
{
int lastReachedVertex = 0;
while (lastReachedVertex < size)
{
if (!reachedVertices[lastReachedVertex])
{
GraphComponent *component = new GraphComponent(this);
std::list<int> *connectedVertices = new std::list<int>();
std::list<int> *nextVertices = new std::list<int>();
nextVertices->push_back(lastReachedVertex);
reachedVertices[lastReachedVertex] = true;
while (!nextVertices->empty())
{
int vertex = nextVertices->front();
nextVertices->pop_front();
connectedVertices->push_back(vertex);
graphComponents[vertex] = component;
Vertices *adjVertices = getAdjacentVertices(vertex,size);
for (Vertices::iterator it = adjVertices->begin(); it != adjVertices->end(); ++it)
{
int adjVertex = *it;
if (!reachedVertices[adjVertex])
{
nextVertices->push_back(adjVertex);
reachedVertices[adjVertex] = true;
}
}
delete adjVertices;
}
delete nextVertices;
component->setVertices(connectedVertices);
graphComponentSet->insert(component);
delete connectedVertices;
}
lastReachedVertex++;
}
for (GraphComponentSet::iterator it = graphComponentSet->begin(); it != graphComponentSet->end(); ++it)
(*it)->buildDataStructure();
}
示例7: dump
/** Dump an entire forest to a DBMS.
*
* FIXME: This should really be using something like ODBC, but ROSE is only configured to use specific DBMS like SQLite3
* or MySQL. Therefore, since we don't need to do any queries, we'll just generate straight SQL as text (the sqlite3x API
* converts all numeric values to text anyway, so there's not really any additional slowdown or loss of precision).
* Therefore, the @p user_name and @p password arguments are unused, and @p server_name is the name of the file to which
* the SQL statements are written. */
void dump(const std::string &server_name, const std::string &user_name, const std::string &password) {
std::ofstream dbc(server_name.c_str());
renumber_vertices();
dump_outputsets(dbc);
dump_inputsets(dbc);
Vertices leaves = get_leaves();
size_t leafnum = 0;
for (Vertices::const_iterator vi=leaves.begin(); vi!=leaves.end(); ++vi, ++leafnum) {
Vertex *vertex = *vi;
const Functions &functions = vertex->get_functions();
dbc <<"insert into simsets (id) values (" <<leafnum <<");\n";
for (Functions::const_iterator fi=functions.begin(); fi!=functions.end(); ++fi)
dbc <<"insert into functions (entry_va, simset_id) values (" <<(*fi)->get_entry_va() <<", " <<leafnum <<");\n";
for (Vertex *v=vertex; v; v=v->parent)
dbc <<"insert into inoutpairs (simset_id, inputset_id, outputset_id) values ("
<<leafnum <<", " <<v->get_level() <<", " <<v->id <<");\n";
}
}
示例8: gnuplot_print_vertices
void gnuplot_print_vertices(std::ostream& out, const Vertices& vertices)
{
for (Vertex_iterator it = vertices.begin(); it != vertices.end(); ++it)
out << (*it) << " " << it->unique_id() << endl;
}
示例9: degree_sort
void degree_sort(Vertices &R){
set_degrees(R); sort(R.begin(), R.end(), desc_degree);
}
示例10: mcqdyn
void mcqdyn(int* maxclique, int &sz){
set_degrees(V); sort(V.begin(),V.end(), desc_degree); init_colors(V);
for(int i = 0; i < (int)V.size() + 1; i++) S[i].i1 = S[i].i2 = 0;
expand_dyn(V); sz = (int)QMAX.size();
for(int i = 0; i < (int)QMAX.size(); i++) maxclique[i] = QMAX[i];
}
示例11: main
int main(int argc, char** argv)
{
if(argc != 3)
return usage(argv[0]);
mark_tag vertex_index(1), vertex_x(2), vertex_y(3), vertex_z(4);
sregex tface_re = bos >> *space >> "TFACE" >> *space >> eos;
sregex vertex_re = bos >> *space >> "VRTX"
>> +space >> (vertex_index=+_d)
>> +space >> (vertex_x=+(digit|'-'|'+'|'.'))
>> +space >> (vertex_y=+(digit|'-'|'+'|'.'))
>> +space >> (vertex_z=+(digit|'-'|'+'|'.'))
>> eos;
sregex triangle_re = bos >> *space >> "TRGL"
>> +space >> (s1=+digit)
>> +space >> (s2=+digit)
>> +space >> (s3=+digit)
>> eos;
sregex end_re = bos >> *space >> "END" >> *space >> eos;
std::ifstream input(argv[1]);
std::ofstream output(argv[2]);
if(!input) {
std::cerr << "Cannot read \"" << argv[1] << "\"!\n";
return EXIT_FAILURE;
}
if(!output) {
std::cerr << "Cannot write to \"" << argv[2] << "\"!\n";
return EXIT_FAILURE;
}
std::string line;
std::getline(input, line);
smatch results;
while(input && ! regex_match(line, tface_re)) // search line "TFACE"
{
std::getline(input, line);
}
std::getline(input, line);
while(input && regex_match(line, results, vertex_re)) {
vertices.push_back(boost::make_tuple(results[vertex_x],
results[vertex_y],
results[vertex_z]));
std::getline(input, line);
}
while(input && regex_match(line, results, triangle_re)) {
std::stringstream s;
int i, j, k;
s << results[1] << " " << results[2] << " " << results[3];
s >> i >> j >> k;
faces.push_back(boost::make_tuple(i, j, k));
std::getline(input, line);
}
if(!input || !regex_match(line, end_re))
return incorrect_input("premature end of file!");
output << "OFF " << vertices.size() << " " << faces.size() << " " << "0\n";
for(Vertices::const_iterator vit = vertices.begin(), vend = vertices.end();
vit != vend; ++vit)
output << boost::get<0>(*vit) << " "
<< boost::get<1>(*vit) << " "
<< boost::get<2>(*vit) << "\n";
for(Faces::const_iterator fit = faces.begin(), fend = faces.end();
fit != fend; ++fit)
output << "3 " << boost::get<0>(*fit)
<< " " << boost::get<1>(*fit)
<< " " << boost::get<2>(*fit) << "\n";
if(output)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
};