Boost logo

Boost Users :

From: Grek (grekaire_at_[hidden])
Date: 2005-02-01 15:38:21


Hi:
 
I am a newbie to the world of Boost.
 
I have a problem in compiling a program. I do not know how to set the path to compile the attached code.
 
My platform is Cygwin
gcc version 3.3.3
 
The boost_1_32_0 subdirectory resides in the Cygwin directory.
 
I tried the following,
 
g++ boost_1_32_0/boost/graph/sourcecode.cpp
 
and it displays the message
boost/config.hpp : No such file or directory
boost/graph/graph_traits.hpp : No such file or directory
boost/graph/adjacency_list.hpp : No such file or directory
boost/graph/dijkstra_shortest_paths.hpp : No such file or directory
 
followed by more error messages. Please refer to the attached code and help me out.
 
Thanks in advance.
 
Sourcecode.cpp

******************************************************************************
#include <boost/config.hpp>
#include <iostream>
#include <fstream>
#include <string>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
using namespace boost;
float maximum(float a[], float mx, int n){
  float max=mx;
  for(int i=0; i<n; ++i){
    if(max < a[i]){
      max=a[i];
    }
  }
  return max;
}
int main()
{
  int num_nodes = 10000;
  int num_PPIs = 50000;
  char node[num_nodes][10], p1[num_PPIs][10], p2[num_PPIs][10];
  char name[num_nodes];
  float wt[num_PPIs], apl, dia, path[num_nodes];
  int i, j, l, l1, l2, mx_len=num_nodes, pl[mx_len];
  typedef adjacency_list < listS, vecS, directedS,
    no_property, property < edge_weight_t, float > > graph_t;
  typedef graph_traits < graph_t >::vertex_descriptor vertex_descriptor;
  typedef graph_traits < graph_t >::edge_descriptor edge_descriptor;
  typedef std::pair<int, int> Edge;
  std::ifstream INF1 ("./data/None.conversion");
  std::ifstream INF2 ("./data/None.before");
  if(!INF1){
    std::cerr << "Cannot find INF1 file." << std::endl;
    return EXIT_FAILURE;
  }
  if(!INF2){
    std::cerr << "Cannot find INF2 file." << std::endl;
    return EXIT_FAILURE;
  }
  //read data
  i=0;
  while(INF1 >> num_nodes >> node[i]){
    ++i;
  }
  INF1.close();
  num_nodes=i;
  i=0;
  while(INF2 >> p1[i] >> p2[i] >> wt[i]){
    wt[i]=1.0;
    ++i;
  }
  INF2.close();
  num_PPIs=i;
  //
  Edge edge_array[num_PPIs];
  for(i=0; i<num_PPIs; ++i){
    for(j=0; j<num_nodes; ++j){
      if(stricmp(p1[i],node[j]) == 0){
 edge_array[i].first=j;
       }
    }
    for(j=0; j<num_nodes; ++j){
      if(stricmp(p2[i],node[j]) == 0){
 edge_array[i].second=j;
      }
    }
  }
  //
  int num_arcs = sizeof(edge_array) / sizeof(Edge);
  std::cout << "0 None " << num_PPIs << " " << num_nodes;
    graph_t g(edge_array, edge_array + num_arcs, wt, num_nodes);
    property_map<graph_t, edge_weight_t>::type weightmap = get(edge_weight, g);
    std::vector<vertex_descriptor> p(num_vertices(g));
    std::vector<float> d(num_vertices(g));
    //
    l1=0;
    l2=0;
    dia=0;
    for(j=1; j<mx_len; ++j){
      pl[j]=0;
    }
    //
    for(int src=0; src<num_nodes; ++src){
      vertex_descriptor s = vertex(src, g);
      dijkstra_shortest_paths(g, s, predecessor_map(&p[0]).distance_map(&d[0]));
      for(j=0; j<num_nodes; ++j){
 if(j == p[j]){ //set self-looping node to zero distance
   d[j]=0;
 }
 if(d[j] > 10000){ //set non-connecting node to zero distance
   d[j]=0;
 }
 path[j]=d[j];
 pl[int(d[j]+0.5)]=pl[int(d[j]+0.5)]+1;
      }
      dia=maximum(path,dia,num_nodes);
    }
    for(l=1; l<=int(dia); ++l){
      l1=l1+pl[l]*l;
      l2=l2+pl[l];
    }
    apl=float(l1)/float(l2);
    std::cout << " " << apl << " " << l1 << " " << l2 << " " << dia << std::endl;
  return EXIT_SUCCESS;
}
**********************************************************************************
 
Cheers
 
Grek
 
 
 

                
---------------------------------
Do you Yahoo!?
 Yahoo! Search presents - Jib Jab's 'Second Term'



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net