Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to use Dijkstra c++ code using array based version
    primarykey
    data
    text
    <p>I need to use (not implement) an array based version of Dijkstras algo .The task is that given a set of line segments(obstacles) and start/end points I have to find and draw the shortest path from start/end point.I have done the calculating part etc..but dont know how to use dijkstras with my code.My code is as follows</p> <pre><code>class Point { public: int x; int y; Point() { } void CopyPoint(Point p) { this-&gt;x=p.x; this-&gt;y=p.y; } }; class NeighbourInfo { public: Point x; Point y; double distance; NeighbourInfo() { distance=0.0; } }; class LineSegment { public: Point Point1; Point Point2; NeighbourInfo neighbours[100]; LineSegment() { } void main()//in this I use my classes and some code to fill out the datastructure { int NoOfSegments=i; for(int j=0;j&lt;NoOfSegments;j++) { for(int k=0;k&lt;NoOfSegments;k++) { if( SimpleIntersect(segments[j],segments[k]) ) { segments[j].neighbours[k].distance=INFINITY; segments[j].neighbours[k].x.CopyPoint(segments[k].Point1); segments[j].neighbours[k].y.CopyPoint(segments[k].Point2); cout&lt;&lt;"Intersect"&lt;&lt;endl; cout&lt;&lt;segments[j].neighbours[k].distance&lt;&lt;endl; } else { segments[j].neighbours[k].distance= EuclidianDistance(segments[j].Point1.x,segments[j].Point1.y,segments[k].Point2.x,segments[k ].Point2.y); segments[j].neighbours[k].x.CopyPoint(segments[k].Point1); segments[j].neighbours[k].y.CopyPoint(segments[k].Point2); } } } } </code></pre> <p>Now I have the distances from each segmnets to all other segments, amd using this data(in neighbourinfo) I want to use array based Dijkstras(restriction ) to trace out the shortest path from start/end points.There is more code , but have shortened the problem for the ease of the reader</p> <p>Please Help!!Thanks and plz no .net lib/code as I am using core C++ only..Thanks in advance</p> <p>But I need the array based version(strictly..) I am not suppose to use any other implemntation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload