Boost logo

Boost Users :

From: Dmitry (dmitry_at_[hidden])
Date: 2006-09-23 16:58:31


Hi All!
I have the following graph:

typedef boost::adjacency_list<
  vecS, ///<Container for edges
  vecS, ///<Container for vertises
  bidirectionalS, ///<Graph is directed with access to in & out edges
  CVertexProperties, CEdgeProperties, ///<Vertex and Edge bundled properties
  property<graph_name_t, double> ///< Just for test purpose
> Graph;

Now I would like to read data from the following ".dot" file (put
max_cycle_ratio to graph_name property):
////////dot file/////////////
digraph article {
        graph [max_cycle_ratio = 5.5] ;
        node [node_delay = 0] ;
        
        edge [edge_delay =1];
        1 -> 1 [edge_weight = 1];
        1 -> 2 [edge_weight = 2];
        1 -> 4 [edge_weight = 7];
        2 -> 2 [edge_weight = 3];
        2 -> 3 [edge_weight = 5];
        3 -> 2 [edge_weight = 4];
        3 -> 4 [edge_weight = 3];
        4 -> 2 [edge_weight = 2];
        4 -> 3 [edge_weight = 8];
}

What should I add to my current code (which is read everything execpt graph
properties) for this?

/////////////code////////////
void make_dynamic_properties(Graph& g, boost::dynamic_properties& p)
{
        // ?????????? ---> p.property("max_cycle_ratio", get_property(g,
graph_name)); How it is this correctly?
        p.property("node_id", get(svertex_name, g));
          p.property("node_delay", get(svertex_delay, g));
        p.property("edge_weight", get(sedge_weight, g));
        //This will be label of the edge on the picture
        p.property("label", get(sedge_weight, g));
        //p.property("label", get(sedge_delay, g));
#ifdef EDGE_COLOR_PROPERTY
        p.property("color", get(&CEdgeProperties::edge_color, g));
#endif
        p.property("edge_delay", get(sedge_delay, g));
}

bool input_data(const char* filename, Graph& g)
{
        try {
                        DPRINTF("Input Data from file: " +
std::string(filename));
                        std::ifstream in(filename);
                        assert(in.good());
                        boost::dynamic_properties p;
                        make_dynamic_properties(g, p);
                        read_graphviz(in, g, p);
                } catch (std::exception& a) {
                        std::cerr << a.what() << std::endl;
                        return false;
                }
          }
        return true;
}
///////////////////////////////////////
Thank you for your patience and tolerance!

Sr. Dima


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