I need to implement Dijikstra's and Floyds algorithm using a linked list !!! can anyone give a code on how to do it !! because i know to implement it using Matrix but am not familiar with the linked list !!
please help me on this !!!

The rules of the implementation are:
1. weights are generated randomly not as input
2. All nodes are connected to each other
3. The code had to be implemented in C

below is the code I have been able to implement so far, but i need to implement Dijiktra nad Floyd in this.

#include <stdio.h>
#include <stdlib.h>

/*
 *
 */
struct node{
    int value;
    struct node *nextNode;
};

int main(int argc, char** argv) {

    int random[15*15-15];
    struct node *pointerArray[5];
    struct node *oneNode;
    int i=0;
    int j=0;
    for(i=0;i<5;i++){
        oneNode = (struct node *) malloc(sizeof (struct node));     // the first node of each row
        oneNode->value = i;
        *(pointerArray+i) = oneNode;
        for(j=0;j<5;j++){
            if(i!=j){
                struct node *anotherNode = (struct node *) malloc(sizeof (struct node));     // the first node of each row
                anotherNode->value = j;
                oneNode->nextNode = anotherNode;
                oneNode = anotherNode;
            }
        }
    }
    struct node *p;
    for(i=0;i<5;i++){
        p = *(pointerArray+i);
        while(1){
            printf("%d",p->value);
            p = p->nextNode;
            if(p!=NULL){
                 printf(" -> ");
            }else{
                break;
            }
        } //  end while
        printf("\n");
    }
    return (EXIT_SUCCESS);
}

Do a google search

Hint ad i++ after the search string... for obvious reasons

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.