Skip to Content.
Sympa Menu

cgal-discuss - [cgal-discuss] Re: Dijkstra's algorithm on surface graph of a polyheron

Subject: CGAL users discussion list

List archive

[cgal-discuss] Re: Dijkstra's algorithm on surface graph of a polyheron


Chronological Thread 
  • From: lhtrang <>
  • To:
  • Subject: [cgal-discuss] Re: Dijkstra's algorithm on surface graph of a polyheron
  • Date: Sat, 1 Dec 2012 03:36:23 -0800 (PST)

Hi all,

thanks for your reply, following is my code. I compile but the error
appeared so long to paste here.
I create polyhedron by reading there vertices of each face and use
P.make_triangle(a, b, c).

Bests,
Trang
-----------------------------------------------------------------------------------------
...
// reading an polyhedron from a file
...

vertex_iterator vit, ve;
// Associate indices to the vertices
int index = 0;
// boost::tie assigns the first and second element of the std::pair
// returned by boost::vertices to the variables vit and ve
for(boost::tie(vit,ve)=boost::vertices(P); vit!=ve; ++vit ){
vertex_descriptor vd = *vit;
vertex_id_map[vd]= index++;
}

// Dijkstra's shortest path needs property maps for the predecessor and
distance
// We first declare a vector
std::vector<vertex_descriptor> predecessor(boost::num_vertices(P));
// and then turn it into a property map
boost::iterator_property_map<std::vector&lt;vertex_descriptor>::iterator,
VertexIdPropertyMap>
predecessor_pmap(predecessor.begin(), vertex_index_pmap);

std::vector<double> distance(boost::num_vertices(P));
boost::iterator_property_map<std::vector&lt;double>::iterator,
VertexIdPropertyMap>
distance_pmap(distance.begin(), vertex_index_pmap);

// start at an arbitrary vertex
vertex_descriptor source = *boost::vertices(P).first;
std::cout << "\nStart dijkstra_shortest_paths at " << source->point()
<<"\n";

// call Dijkstra algorithm ...
boost::dijkstra_shortest_paths(P, source,
distance_map(distance_pmap)
.predecessor_map(predecessor_pmap)
.vertex_index_map(vertex_index_pmap));
---------------------------------------------------------------------------------------------------------------



--
View this message in context:
http://cgal-discuss.949826.n4.nabble.com/Dijkstra-s-algorithm-on-surface-graph-of-a-polyheron-tp4656323p4656331.html
Sent from the cgal-discuss mailing list archive at Nabble.com.


  • [cgal-discuss] Re: Dijkstra's algorithm on surface graph of a polyheron, lhtrang, 12/01/2012

Archive powered by MHonArc 2.6.18.

Top of Page