src/work/marci_graph_demo.cc
changeset 15 e41c71268807
parent 9 a9ed3f1c2c63
child 19 3151a1026db9
equal deleted inserted replaced
0:0a60a18bac1c 1:3ed7ed98dcb8
    27     for(int j=0; j!=8; ++j) {
    27     for(int j=0; j!=8; ++j) {
    28       if ((i<j)&&(i+j)%3) G.add_edge(vector_of_node_iterators[i], vector_of_node_iterators[j]);
    28       if ((i<j)&&(i+j)%3) G.add_edge(vector_of_node_iterators[i], vector_of_node_iterators[j]);
    29     }  
    29     }  
    30 
    30 
    31   std::cout << "We construct a directed graph on the node set {0,1,2,...,7}," <<std::endl << "i-->j is arc iff i<j and (i+j)%3." << std::endl;
    31   std::cout << "We construct a directed graph on the node set {0,1,2,...,7}," <<std::endl << "i-->j is arc iff i<j and (i+j)%3." << std::endl;
    32   std::cout << "number of nodes: " << number_of<each_node_iterator>(G.first_node()) << std::endl;
    32   std::cout << "number of nodes: " << number_of(G.first_node()) << std::endl;
    33 
    33 
    34   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
    34   for(each_node_iterator i=G.first_node(); i.is_valid(); ++i) {
    35     std::cout << "node " << G.id(i) << std::endl;
    35     std::cout << "node " << G.id(i) << std::endl;
    36     std::cout << " outdegree (out_edge_iterator): " << number_of(G.first_out_edge(i)) << " "; 
    36     std::cout << " outdegree (out_edge_iterator): " << number_of(G.first_out_edge(i)) << " "; 
    37     for(out_edge_iterator j=G.first_out_edge(i); j.is_valid(); ++j) { 
    37     for(out_edge_iterator j=G.first_out_edge(i); j.is_valid(); ++j) { 
    38       std::cout << "(" << G.id(G.tail(j)) << "--" << G.id(j) << "->" << G.id(G.head(j)) << ") ";
    38       std::cout << "(" << G.id(G.tail(j)) << "--" << G.id(j) << "->" << G.id(G.head(j)) << ") ";
    39     }
    39     }
    40     std::cout << std::endl; 
    40     std::cout << std::endl; 
       
    41 
       
    42     std::cout<< " ";
       
    43     for(out_edge_iterator j=G.first_out_edge(i); j.is_valid(); ++j) { 
       
    44       std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; } 
       
    45     std::cout<<std::endl;
       
    46 
    41     std::cout << " indegree: (in_edge_oterator) " << number_of(G.first_in_edge(i)) << " ";
    47     std::cout << " indegree: (in_edge_oterator) " << number_of(G.first_in_edge(i)) << " ";
    42     for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) { 
    48     for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) { 
    43       std::cout << j << " "; } 
    49       std::cout << j << " "; } 
    44     std::cout << std::endl;
    50     std::cout << std::endl;
       
    51 
       
    52     std::cout<< " ";
       
    53     for(in_edge_iterator j=G.first_in_edge(i); j.is_valid(); ++j) { 
       
    54       std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; } 
       
    55     std::cout<<std::endl;
       
    56 
    45     std::cout << " degree: (sym_edge_iterator) " << number_of(G.first_sym_edge(i)) << " ";
    57     std::cout << " degree: (sym_edge_iterator) " << number_of(G.first_sym_edge(i)) << " ";
    46     for(sym_edge_iterator j=G.first_sym_edge(i); j.is_valid(); ++j) { 
    58     for(sym_edge_iterator j=G.first_sym_edge(i); j.is_valid(); ++j) { 
    47       std::cout << j << " "; } 
    59       std::cout << j << " "; } 
       
    60     std::cout<<std::endl;
       
    61 
       
    62     std::cout<< " ";
       
    63     for(sym_edge_iterator j=G.first_sym_edge(i); j.is_valid(); ++j) { 
       
    64       std::cout << G.a_node(j) << "->" << G.b_node(j) << " "; } 
    48     std::cout<<std::endl;
    65     std::cout<<std::endl;
    49   }
    66   }
    50 
    67 
    51   std::cout << "all edges: ";
    68   std::cout << "all edges: ";
    52   for(each_edge_iterator i=G.first_edge(); i.is_valid(); ++i) {
    69   for(each_edge_iterator i=G.first_edge(); i.is_valid(); ++i) {