本文整理汇总了C++中graph::Node类的典型用法代码示例。如果您正苦于以下问题:C++ Node类的具体用法?C++ Node怎么用?C++ Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(VertexWeightedGraphTest, testGetNode)
{
Graph::Node *n;
n = wmg->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
}
示例2: buildGraph
void ORD::buildGraph() {
Graph::GraphCreatorFile creator(this->filename);
Graph::GraphUtil util;
Graph::GraphProperties properties;
int wr;
int size;
MPI_Comm_size(comm, &size);
MPI_Comm_rank(comm, &wr);
G = creator.create_weighted_mutable_graph();
properties.make_canonical(G);
char compname[512];
if (!properties.is_connected(G))
{
Graph::GraphReaderWriterFactory factory;
Graph::VertexWeightedGraph *H;
// Since we are going to proceed with processing largest
// component , set a mark as not original and write largest
// component into a file.
this->set_original(false);
vector<list<int> *> members;
int comp;
comp = util.find_all_components(G, &members);
DEBUG("found %d components\n", comp);
int i = 0;
int gsize = 0;
int index = 0;
for (int j = 0; j < comp; j++)
{
i = members[j]->size();
if (i > gsize)
{
gsize = i;
index = j;
sprintf(compname, "%s_%d_comp", filename.c_str(), gsize);
DEBUG("new larger comp : %d\n", gsize);
}
}
this->set_filename(compname);
H = creator.create_component(G, members[index], true);
delete G;
G = H;
// Change the label into 1-base DIMACS format
int j = 0;
int gs = G->get_num_nodes();
Graph::Node *n;
for (int i = 0 ; i < gs; i++)
{
n = G->get_node(i);
n->set_label(i+1);
}
}
}
示例3:
TEST_F(MutableGraphTest, testGetNode)
{
Graph::Node *n;
n = mg->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
}
示例4: remove_all_edges
void remove_all_edges(int i){
list<int>::iterator it;
Graph::Node *n = mg->get_node(i);
list<int> nbrs = n->get_nbrs();
for(it = nbrs.begin(); it != nbrs.end(); ++it){
mg->remove_edge(i, *it);
}
}
示例5:
TEST_F(MutableGraphTest, testIsEdge)
{
Graph::Node *n;
n = mg->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
EXPECT_TRUE(mg->is_edge(108, 100));
}
示例6: while
bool
BasicBlock::dominatedBy(BasicBlock *that)
{
Graph::Node *bn = &that->dom;
Graph::Node *dn = &this->dom;
while (dn && dn != bn)
dn = dn->parent();
return dn != NULL;
}
示例7:
TEST_F(GraphPropertyTest, testClique)
{
Graph::Node *n;
n = mg->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
EXPECT_FALSE(properties.is_clique(mg, &nbrs));
nbrs.push_back(108);
properties.make_clique(mg, &nbrs);
EXPECT_TRUE(properties.is_clique(mg, &nbrs));
}
示例8:
TEST_F(MetisGraphReaderTest, testGetNode)
{
//dim_writer->write_graph(g);
creator.set_file_name("data/1dc.128.met");
creator.set_graph_type("Metis");
g = creator.create_graph();
Graph::Node *n;
n = g->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
}
示例9:
TEST_F(DIMACSGraphWriterTest, testGetNode)
{
dim_writer->write_graph(g);
creator.set_file_name("../data/1dc.128.out");
creator.set_graph_type("DIMACS");
g = creator.create_graph();
Graph::Node *n;
n = g->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
}
示例10:
TEST_F(GraphReaderWriterFactoryTest, testDimacsGraphWriterGetNode)
{
gw = factory.create_writer("dimacs", "data/dimacsout.out");
gw->write_graph(g);
creator.set_file_name("data/dimacsout.out");
creator.set_graph_type("dimacs");
g = creator.create_graph();
Graph::Node *n;
n = g->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
}
示例11:
TEST_F(GraphTest, testIsEdge)
{
Graph::Node *n;
n = g->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
EXPECT_TRUE(g->is_edge(108, 100));
n = g->get_node(80);
list<int> nbrs2 = n->get_nbrs();
EXPECT_EQ(22, nbrs2.size());
EXPECT_FALSE(g->is_edge(80, 12));
}
示例12:
TEST_F(MetisGraphWriterTest, testIsEdge)
{
dim_writer->write_graph(g);
creator.set_file_name("../data/1dc.128.met");
creator.set_graph_type("Metis");
g = creator.create_graph();
Graph::Node *n;
n = g->get_node(108);
list<int> nbrs = n->get_nbrs();
EXPECT_EQ(24, nbrs.size());
EXPECT_TRUE(g->is_edge(108, 100));
}
示例13: separateConnectedComponents
void LazyConstraintCallback::separateConnectedComponents( Graph const & g
, GraphVariables const & vars
, Graph::Node const & root
, NodeSetVector const & nonZeroNodesComponents
, int & nCuts
) {
IloExpr rhs( getEnv() );
for ( const NodeSet& S : nonZeroNodesComponents ) {
// only consider the non-zero components that don't contain the root
auto it = S.find( root );
if ( it == S.end() || it->componentIndex() != root.componentIndex() ) {
// determine dS
NodeSet dS;
for ( Graph::Node i : S ) {
for ( Graph::Edge e : g.incEdges( i ) ) {
Graph::Node j = g.oppositeNode( i, e );
if ( S.find( j ) == S.end() )
{
dS.insert( j );
}
}
}
constructRHS( vars, dS, S, rhs );
for ( Graph::Node i : S ) {
assert( isValid( g, i, dS, S ) );
add( vars.xVars[vars.nodeToIndex[i]] <= rhs, IloCplex::UseCutPurge ).end();
++nCuts;
}
}
}
rhs.end();
}
示例14: outputMetisFormat
void ORD::outputMetisFormat() {
int n = G->get_num_nodes();
cout << n << " " << G->get_num_edges() << endl;
for (int i = 0; i < n; i++)
{
Graph::Node *no = G->get_node(i);
list<int> *l = no->get_nbrs_ptr();
list<int>::iterator it = l->begin();
for (; it != l->end(); ++it)
{
cout << (*it)+1 << " ";
}
cout << endl;
}
}
示例15: diffImageStatus
/**
* @brief Process the difference between 2 readers and return status.
*/
EImageStatus diffImageStatus(Graph::Node& read1, Graph::Node& read2, Graph::Node& stat, Graph& graph, const bfs::path& filename1, const bfs::path& filename2)
{
if (bfs::exists(filename1) == 0 || bfs::exists(filename2) == 0)
return eImageStatusNoFile;
if (bfs::file_size(filename1) == 0 || bfs::file_size(filename2) == 0)
return eImageStatusFileSizeError;
try
{
// Setup parameters
read1.getParam("filename").setValue(filename1.string());
read2.getParam("filename").setValue(filename2.string());
if( !verbose )
std::cout.rdbuf(0);
graph.compute(stat);
std::cout.rdbuf(_stdCout);
if( verbose )
{
std::cout << "diff = ";
for (unsigned int i = 0; i < 3; ++i)
{
std::cout << stat.getParam("quality").getDoubleValueAtIndex(i) << " ";
}
std::cout << std::endl;
}
for (unsigned int i = 0; i < 3; ++i)
{
if (stat.getParam("quality").getDoubleValueAtIndex(i) != 0.0 )
return eImageStatusDiffNotNull;
}
//std::cout << stat << std::endl;
return eImageStatusDiffNull;
}
catch (...)
{
std::cerr << boost::current_exception() << std::endl;
std::cerr << boost::current_exception_diagnostic_information() << std::endl;
return eImageStatusImageError;
}
}