Okay, so as ussual I'm having a lot of problems with a code and I need a lot of help along the way, but I'm just going to break it down into simple questions as I go. I am taking data from an input file that is a .txt that I need to form into a graph to perform Dijkstra’s shortest path algoritum on. The input file is formatted as such: * Vertices: Location1, Location2, Location3, … ,LocationN Edges: (Location1, Location2, IntegerWeightValue) (Location2, Location3, IntegerWeightValue) … (Location1, LocationN, IntegerWeightValue)* 1.) I know I can skip the first line with just … |
+0 forum
28 | ||

I currently have a program that can take a text file and inport the data that I need (names or locations as well as the distances between them) and I need to take that data and for a graph in boost so that I can do one of three things, use Dijkstra’s to find the shortest path between two nodes, use a minimum spanning tree to figure out the shortest way to connect every node, and how to visit every node only once on the shortest path. I import the data as follows: std::getline(fin, tempString); //Location1, Location2, ... std::stringstream tempSS(tempString); … |
+0 forum
0 | ||

I am trying to create Dijkstra's algorithm for a weighted graph, and have a flaw, I believe, in the implementation of the basic algorithm. It only visits the nearest nodes, checks the edges, but nothing else. Right now, I'm afraid I'm too close to this to see what's going on. Can anybody point me in the right direction? Input file: 0 0 1 2 0 2 4 1 2 1 1 3 5 2 4 3 3 4 1 Output: Enter the name of the file: a.txt The shortest distance from 0 to all the nodes is 0 : 2 … |
+0 forum
1 | ||

Hi i've been working on a piece of homework we're I've been asked to implement a 2d grid in opengl and extend Dijkstra's algorithm to A star, so far i've been able to get the 2d grid running with Dijkstra's algorithm with not too many problems but my current extenstion to A star has me scratching my head, i'm just wondering if I'm approaching it all wrong or if I'm going in the right direction with just a few careless mistakes. So my main question is can you see what I am doing wrong? Am I calculating the Manhatten distance … |
+0 forum
5 | ||

i am doing a group project concerning graph my part is finding the minimal cost the teacher tried to help us out with the group work by putting up code for the parts for use to follow. i have errors when i compiled the code that the teacher give. the error is with followPath it said that the method followPath int is not declared with type Graph. no matter what i did to fix it it did not work so i need help plus she said it needed modification but it due in another day and since i am still … |
+0 forum
3 | ||

Hello! I want to ask you guys if anyone can help me correct my current program to read graph from a file instead of adding manual matrix in program. Example graph: graph.txt 8 1 2 3 1 3 6 1 8 1 2 3 2 2 8 2 3 4 1 4 5 6 4 6 3 4 7 4 5 6 3 6 7 2 7 8 10 code: #include <iostream> #include <vector> using namespace std; const double inf = 1000.0; const int nil = -1; void meni() { cout<< "1 Vnos podatkov - rocni" << endl << "2 … |
+0 forum
2 | ||

i am working in Dijkstra code.which i want to get the vertexes from user by using Array list.but there is a problem in computepath method i can't solve it. [CODE] public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("insert the number of Vertexes:"); int nv=input.nextInt();//nv = number of vertexes Integer tmp; HashMap<String , Vertex> h = new HashMap<String , Vertex>(); ArrayList <Vertex > a = new ArrayList<Vertex>(); for(Integer i = 0 ; i < nv ; i++){ String str; str = "v"+Integer.toString(i); Vertex buff = new Vertex(str); //a[i] = new Vertex(str); a.add(buff); h.put(str, a.get(i)); str = "" … |
+0 forum
9 | ||

Hello, I got stuck trying to solve the following problem in Python. I understand that I somehow need to implement Dijkstra's algorithm to solve this problem, but how I've no idea. [B]Inside a room, there is a monster with N heads, and a human (with 1 head). The human has two laser guns. The first gun, A destroys C1 heads when fired and the second gun,B destroys C2 heads when fired [The guns may destroy both the monster's as well as human heads, but the guns prioritize monster heads over human ones]. Also, if after the firing of the gun … |
+0 forum
11 |

The End.