-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgraphl.h
75 lines (63 loc) · 2.29 KB
/
graphl.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// --------------------- graphl.h -----------------------------------------
//
// Shyawn Karim, CSS 343
// Created: October 26, 2015
// Last Modified: Novemeber 12, 2015
// --------------------------------------------------------------
// Purpose: Implement Dijkstra's shortest path algorithm by reading in a
// data file consisting of many lines and be able to find the lowest cost
// paths. Then display the cost and path from every node to to every
// other node.
// --------------------------------------------------------------
// Assumptions: All input data is assumed to be correctly formatted
// and valid.
// --------------------------------------------------------------
#ifndef DIJKSTRASSHORTESTPATH_GRAPHL_H
#define DIJKSTRASSHORTESTPATH_GRAPHL_H
#include "nodedata.h"
#include <iostream>
#include <fstream>
using namespace std;
int const MAXNODES_L = 101; // const size of an array
//-------------------------- class GraphL ---------------------------------
// ADT: GraphL calculates depth-first algorithm (search alway starts at
// node #1).Reads data from provided data file, and find the depth-firts
// recovery path. Also, display all inforamtion of the current GraphL.
//
// Implementation and assumptions:
// -- Implemenet as Graph by using array and linked list
// -- Implemenet depth-fist algorithm
// -- Assumption: the data file has to be correct in order to build
// object GraphL.
//---------------------------------------------------------------------------
class GraphL
{
public:
// Constructor and Destructor
GraphL();
~GraphL();
// Functions
void buildGraph(ifstream&);
void depthFirstSearch();
void displayGraph();
private:
int size;
struct EdgeNode; // struct declaration
struct GraphNode
{
EdgeNode* edgeHead; // head of the list of edges
NodeData* data; // data information about each node
bool visited;
};
GraphNode node_array[MAXNODES_L];
struct EdgeNode
{
int adjGraphNode; // subscript of the adjacent graph node
EdgeNode* nextEdge; // next node
};
// Delete object
void makeEmpty();
// helper for depthFirstSearch()
void depthFirstSearchHelper(int v);
};
#endif //DIJKSTRASSHORTESTPATH_GRAPHL_H