I got this algorythm implemention that makes a list of every path from a source node to destiny nodes, and also return the shortest path between them. My problem is, i am a bit lost with the code and am not sure of how to load the graph into the function (the main function) nor if it is possible to specify the destiny node...Code:#define INFINITY (MAX_INT - 1) typedef struct { int weight; /* inútil até agora */ int dest; /* indica o destino da ligação (ex. 4 -> 6, dest = 6) */ } DijkEdge; typedef struct { DijkEdge* connections; /* An array of edges which has this as the starting node (conjunto de ligações deste nodo) */ int numconnect; /* penso que seja a origem da ligação, no exemplo ali em cima numconnect = 4 (creio) */ int distance; /* é usado e modificado pla função */ int isDead; /* "" "" "" */ } Vertex; void Dijkstra(Vertex* graph, int nodecount, int source) { for(int i = 0; i < nodecount; i++) { if(i == source) { graph[i].distance = 0; graph[i].isDead = 0; } else { graph[i].distance = INFINITY; graph[i].isDead = 0; } } for(int i = 0; i < nodecount; i++) { int next; int min = INFINITY+1; for(int j = 0; j < nodecount; j++) { if(!graph[j].isDead && graph[j].distance < min) { next = j; min = graph[j].distance; } } for(int j = 0; j < graph[next].numconnect; j++) { if(graph[graph[next].connections[j].dest].distance > graph[next].distance + graph[next].connections[j].weight) { graph[graph[next].connections[j].dest].distance = graph[next].distance + graph[next].connections[j].weight; } } graph[next].isDead = 1; } for(int i = 0; i < nodecount; i++) { /* este ciclo é pra ser substituido por outro que escreva as funcionalidades desejadas */ printf("The distance between nodes %i and %i is %i", source, i, graph[i].distance); } }

Can anyone enlighten me please? I hope i was clear enough :\