Programming/DS SorceCode 썸네일형 리스트형 WGraph.h : 가중치 그래프 클래스 #pragma once#ifndef ___WGraph#define ___WGraph//WGraph.h : 가중치 그래프 클래스#include "AdjMatGraph.h"#define INF 9999//값이 INF 이상이면 간선이 없음 //가중치 그래프를 표현하는 클래스class WGraph : public AdjMatGrapgh { //AdjMatGraph 클래스를 상속public:void insertEdge(int u, int v, int weight) {if (weight > INF) weight = INF;setEdge(w, v, weight);}bool hasEdge(int i, int j) { return getEdge(i, j) < INF; }void load(const char* filena.. 더보기 TopoSortGraph.h : 위상 정렬 기능이 추가된 인접 리스트 기반 그래프 #pragma once#ifndef ___TopoSort#define ___TopoSort//TopoSortGraph.h : 위상 정렬 기능이 추가된 인접 리스트 기반 그래프#include "AdjListGraph.h"#include "ArrayStack.h" class TopoSortGraph : public AdjListGraph {int inDeg[MAX_VTXS];//정점의 진입차수public:void insertDirEdge(int u, int v) {//방향성 간선 삽입 연산adj[u] = new Node(v, adj[u]);}// 위상정렬을 수행한다.void TopoSort() {//모든 정점의 진입 차수를 계산 for (int i = 0; i < size; i++)//초기화inDeg[i] .. 더보기 SrchALGraph.h ; 탐색 기능이 추가된 인접 리스트 기반 그래프 클래스 #pragma once#ifndef ___SrchALGraph#define ___SrchALGraph//SrchALGraph.h ; 탐색 기능이 추가된 인접 리스트 기반 그래프 클래스#include "AdjListGraph.h"#include "CircularQueue.h" class SrchALGraph : public AdjListGraph {bool visited[MAX_VTXS];//정점의 방문 정보public:void resetVisited() {//모든 정점을 방문하지 않았다고 설정for (int i = 0; i .. 더보기 SrchAMGraph : 탐색 기능이 추가된 행렬 기반 그래프 클래스 #pragma once#ifndef ___SrchAMGragh#define ___SrchAMGraph//SrchAMGraph : 탐색 기능이 추가된 행렬 기반 그래프 클래스#include "AdjMatGraph.h"#include "CircularQueue.h"class SrchAMGraph : public AdjMatGrapgh {bool visited[MAX_VTXS];//정점의 방문 정보public:void resetVisited() {//모든 정점을 방문하지 않았다고 설정for (int i = 0; i < size; i++)visited[i] = false;}bool isLinked(int u, int v) { return getEdge(u, v) != 0; } //깊이 우선 탐색 함수void D.. 더보기 AdjListGraph.h : 인접 리스트를 이용한 그래프 클래스 #pragma once#ifndef ___AdjListGraph#define ___AdjListGraph//AdjListGraph.h : 인접 리스트를 이용한 그래프 클래스#include "Node_Adj.h"//연결 리스트를 위한 노드 그래프 클래스 포함#define MAX_VTXS256class AdjListGraph {protected:int size;//정점의 개수char vertices[MAX_VTXS];//정점 정보(응용에 따라 확장 필요)Node* adj[MAX_VTXS];//각 정점의 인접 리스트public:AdjListGraph() : size(0) {}~AdjListGraph() { reset(); }void reset(void) {for (int i = 0; i < size; i++).. 더보기 Node.h : 인접 리스트를 이용한 그래프를 위한 노드 클래스 #pragma once#ifndef ___Node_Adj#define ___Node_Adj//Node.h : 인접 리스트를 이용한 그래프를 위한 노드 클래스#include class Node {protected:int id;//정점의 idNode* link;//다음 노드의 포인터public:Node(int i, Node* l=NULL) : id(i), link(l){}~Node() { if (link != NULL) delete link; }int getId() { return id; }Node* getLink() { return link; }void setLink(Node* l) { link = l; }}; #endif // !___Node_Adj 더보기 AdjMatGraph.h : 인접 행렬을 위한 그래프 클래스 #pragma once#ifndef ___AdjMatGraph#define ___AdjMatGraph//AdjMatGraph.h : 인접 행렬을 위한 그래프 클래스#include #define MAX_VTXS 256//표현 가능한 최대 정점의 개수 class AdjMatGrapgh {protected:int size;//정점의 개수char vertices[MAX_VTXS];//정점의 이름int adj[MAX_VTXS][MAX_VTXS];//인접 행렬public:AdjMatGrapgh() { reset(); }char getVertex(int i) { return vertices[i]; }int getEdge(int i, int j) { return adj[i][j]; }void setEdge(int i,.. 더보기 MaxHeap.h : 배열을 이용한 최대 힙 클래스 #pragma once#ifndef ___MaxHeap#define ___MazHeap//MaxHeap.h : 배열을 이용한 최대 힙 클래스#include "HeapNode.h"#define MAX_ELEMENT 200class MaxHeap {HeapNode node[MAX_ELEMENT];//요소의 배열int size;//힙의 현재 요소의 개수public:MaxHeap() : size(0) {}bool isEmpty() { return size == 0; }bool isFull() { return size == MAX_ELEMENT - 1; } HeapNode& getParent(int i) { return node[i / 2]; }HeapNode& getLeft(int i) { return node.. 더보기 이전 1 2 3 4 5 6 7 8 다음