Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
P

progmateur

@progmateur
About
Posts
1
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Graph Theory - Dijkstras algorithm c++
    P progmateur

    Please tell me how to construct the path matrix from Dijkstra and Floyd algorithm, For Dijkstra ,my implementation in c++ is attached. (I am new to c++ ,is the object orientation correct btw)

    #include
    #include
    #include
    #include

    using namespace std;
    template
    class MathematicalSet
    {
    private:
    T *Set;
    int n;
    friend class Dijkstra;
    public:
    MathematicalSet()
    {}
    MathematicalSet(int x)
    {
    n=x;
    Set=new T[n];
    }
    void initialiseSet(int x)
    {
    n=x;
    //Dynamic allocation of the members of the set
    Set=new T[n];
    }

    };
    class Graph
    {
    protected:
    int **G;
    int Vertices;
    public:
    Graph(){}
    /*
    Graph(int V)
    {
    Vertices=V;
    G=new int*[Vertices];
    for(int i=0;i>Vertices;

    G=new int\*\[Vertices\];
    for(int i=0;i\>G\[i\]\[j\];
    		}
    	}
    

    }
    void Graph::displayGraph()
    {
    cout<<"Number of vertices : "< Distance;
    MathematicalSet Included;
    public:
    Dijkstra(int sourceV=0)//by default source vertex is the Vertex[0]
    {
    sourceVertex=sourceV;
    Distance.n=Vertices;
    Distance.Set=new int[Vertices];
    Included.n=Vertices;
    Included.Set=new bool[Vertices];
    }
    void displaySolution();
    int minimumDistance();
    void operate();
    };
    //Actual Dijkstra's Algorithm implementation
    void Dijkstra::operate()
    {
    for(int i=0;i0 && Distance.Set[minVertex]!=INT_MAX)
    {
    if(Distance.Set[minVertex]+G[minVertex][v]

    C / C++ / MFC c++ algorithms data-structures tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups