Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1103261
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:18:58+00:00 2026-05-17T01:18:58+00:00

I need to use (not implement) an array based version of Dijkstras algo .The

  • 0

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

class Point
{
public:
int x;
int y;
Point()
{

}

void CopyPoint(Point p)
{
this->x=p.x;
this->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<NoOfSegments;j++)
 {
 for(int k=0;k<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<<"Intersect"<<endl;
   cout<<segments[j].neighbours[k].distance<<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);

}
}
}

}

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

Please Help!!Thanks and plz no .net lib/code as I am using core C++ only..Thanks in advance

But I need the array based version(strictly..) I am not suppose to use any other implemntation.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:18:59+00:00Added an answer on May 17, 2026 at 1:18 am

    Dijkstras

    This is how Dijkstra’s works:
    Its not a simple algorithm. So you will have to map this algorithm to your own code.
    But good luck.

    List<Nodes>    found;     // All processed nodes;
    List<Nodes>    front;     // All nodes that have been reached (but not processed)
                              // This list is sorted by the cost of getting to this node.
    List<Nodes>    remaining; // All nodes that have not been explored.
    
    remaining.remove(startNode);
    front.add(startNode);
    startNode.setCost(0); // Cost nothing to get to start.
    
    while(!front.empty())
    {
        Node       current = front.getFirstNode();
        front.remove(current);
        found.add(current);
    
        if (current == endNode)
        {    return current.cost(); // we found the end
        }
    
        List<Edge> edges   = current.getEdges();
    
        for(loop = edges.begin(); loop != edges.end(); ++loop)
        {
            Node   dst = edge.getDst();
            if (found.find(dst) != found.end())
            {   continue; // If we have already processed this node ignore it.
            }
    
    
            // The cost to get here. Is the cost to get to the last node.
            // Plus the cost to traverse the edge.
            int    cost = current.cost() + loop.cost();
            Node   f    = front.find(dst);
            if (f != front.end())
            {
                f.setCost(std::min(f.cost(), cost));
                continue;  // If the node is on the front line just update the cost
                           // Then continue with the next node.
            }
    
            // Its a new node.
            // remove it from the remaining and add it to the front (setting the cost).
            remaining.remove(dst);
            front.add(dst);
            dst.setCost(cost);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use a function on a vector that does not take a
I need to use the ManagedBuildManager but my Eclipse is not seeing it. What
I need to use basic javascript here and I'm not well versed with it.
I need to explain myself why I do not use static methods/propertis. For example,
I have not used valgrind before, but I need to use it to check
Can someone please explain me why would a UDP Server not need to use
I need to rewrite this query and I'm not allowed to use a subquery.
I'm not sure when it is appropriate to use a cursor. I need to
I'm trying to implement search code in my CoreData-based iPhone app. I'm not sure
I need to make a Javascript object that would behave as an associative array,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.