⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 graph.h

📁 I implement Dijkstra s Single Source Shortest Path, say SSP, algorithm for directed graphs using a s
💻 H
字号:
// Graph.h: interface for the Graph class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(GRAPH_H)
#define GRAPH_H

#define INIT_CAPACITY 20;
//#define INFINITY 2000;

#include "Result.h"
#include "DistSet.h"
#include "ArraySet.h"
#include "FHeap.h"
#include "PHeap.h"
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <time.h>

using namespace std;

 
struct Edge{
	int node;
	int cost;
	Edge * next;
};

struct Node{
	int degree;
	Edge * e;
};

class Graph  
{	
public:
	/*Initialized the graph from file*/
	Graph(const char * fileName);
	/*Initialized the graph randomly*/
	Graph(int, int);
	/*Initialized the graph from*/
	Graph();

	~Graph();

	/*SSP Algorithm using Dijkstra*/
	Result DijkstraSSP(int node, DistSet * dist_set);
	Node * adj_list;
	void testInput(void);

private:
	/*increase the size of adj-listin the step of 20*/
	void extendAdjList(int newlength);
	/*Add a new edge into the graph*/
	bool addNewEdge(int from, Edge * e);
	void initialize(void);
	void buildGraph(istream & is);
	void clear(void);
	bool isConnected(void);
	void DFS(int startNode, bool* isVisited);

private:
	/*number of edge*/
	int edge_num;
	int node_num;
	int adj_length;	

public:
	int getNodeNum(void)
	{
		return node_num;
	}
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -