-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraph.h
More file actions
49 lines (43 loc) · 886 Bytes
/
Graph.h
File metadata and controls
49 lines (43 loc) · 886 Bytes
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
#pragma once
#include <string>
#include <fstream>
struct Cell
{
Cell()
{
value = -1;
next = nullptr;
}
Cell(int v)
{
value = v;
next = nullptr;
}
int value;
Cell* next;
};
class Graph
{
public:
bool Build(std::string filename);
bool Insert(std::string line);
bool Delete(std::string line);
void GetSize(int& n, int& l) const;
int ConnectedComponents();
int ComputeSpanningTree();
int FindShortestPath(int start, int end); // NOT COMPLETED
private:
int AddNode(int n);
int FindIndex(int n);
bool Insert(int a, int b);
Cell* AddLink(Cell* cell, int value);
bool RemoveLink(Cell& cell, int value);
void DepthFirstSearch(int index, bool* visited);
int BreadthFirstSearch(int start, int end, int currentDist);
private:
Cell* Elements = nullptr;
int nodes = 0;
int links = 0;
int maxSize = 0;
void ExtractNumbers(std::string line, int& a, int& b);
};