Click here to Skip to main content
15,899,754 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Creating a setup for installtion of MFC Application Pin
Hamid_RT16-Nov-08 20:37
Hamid_RT16-Nov-08 20:37 
QuestionAccessing column data from multiple tables in oracle 10g to a single form of SDI Application Pin
Divya Lalwani16-Nov-08 19:22
Divya Lalwani16-Nov-08 19:22 
QuestionExecuting program error. Pin
Nikesh Jagtap16-Nov-08 18:47
Nikesh Jagtap16-Nov-08 18:47 
QuestionRe: Executing program error. Pin
David Crow17-Nov-08 3:27
David Crow17-Nov-08 3:27 
QuestionWrite data n PDF and Excel Pin
MsmVc16-Nov-08 17:18
MsmVc16-Nov-08 17:18 
AnswerRe: Write data n PDF and Excel Pin
Hamid_RT16-Nov-08 17:56
Hamid_RT16-Nov-08 17:56 
QuestionIncorrect binary path set during Win32 Service installation Pin
Member 569752116-Nov-08 16:00
Member 569752116-Nov-08 16:00 
Questionminimum spanning tree Pin
Sadaiyappan16-Nov-08 9:54
Sadaiyappan16-Nov-08 9:54 
Please help me use this to create a function that will find the minimum spanning tree. I am unsure of how to use the findEdge function to find edges that I can measure their weights for to find the minimum tree. Please help. Hi this is the code for a graph from my book:

#ifndef EDGE_H
#define EDGE_H

class Edge
{
public:
	int v, w, weight;
	Edge(int firstVertex, int secondVertex, int edgeWeight)
	{
		v = firstVertex;
		w = secondVertex;
		weight = edgeWeight;
	}
};

#endif


#ifndef GRAPH_H
#define GRAPH_H

#include <vector>
#include <list>
#include <map>
#include "Edge.h"

using namespace std;

class Graph
{
public:
	int numVertices;
	int numEdges;

	vector<map<int, int> > adjList;

	Graph(int n);

	int getNumVertices() const;

	int getNumEdges() const;

	int getWeight(Edge e) const;

	void add(Edge e);

	void remove(Edge e);

	map<int, int>::iterator findEdge(int v, int w);
};

#endif



#include "Graph.h"

Graph::Graph(int n)
{
	map<int, int>element;
	adjList.assign(n, element);
	numVertices = n;
}

int Graph::getNumVertices() const
{
	return numVertices;
}

int Graph::getNumEdges() const
{
	return numEdges;
}

int Graph::getWeight(Edge e) const
{
	return e.weight;
}

void Graph::add(Edge e)
{
	int v = e.v,
		w = e.w,
		weight = e.weight;
	adjList[v].insert(make_pair(w, weight));
	adjList[w].insert(make_pair(v, weight));
	numEdges++;
}

void Graph::remove(Edge e)
{
	int v = e.v,
		w = e.w,
		weight = e.weight;
	adjList[e.v].erase(w);
	adjList[e.w].erase(v);
	numEdges--;
}

map<int, int>::iterator Graph::findEdge(int v, int w)
{
	map<int, int> m = adjList[v];
	map<int, int>::iterator iter = m.find(w);

	return iter;
}

AnswerRe: minimum spanning tree Pin
Sarath C16-Nov-08 19:11
Sarath C16-Nov-08 19:11 
Questionhey plz fix this code it got errors urgent Pin
jazikhan00116-Nov-08 8:46
jazikhan00116-Nov-08 8:46 
AnswerRe: hey plz fix this code it got errors urgent Pin
Peter Weyzen16-Nov-08 9:46
Peter Weyzen16-Nov-08 9:46 
GeneralRe: hey plz fix this code it got errors urgent Pin
jazikhan00116-Nov-08 9:50
jazikhan00116-Nov-08 9:50 
AnswerRe: hey plz fix this code it got errors urgent Pin
22491717-Nov-08 12:42
22491717-Nov-08 12:42 
AnswerRe: hey plz fix this code it got errors urgent Pin
Iain Clarke, Warrior Programmer18-Nov-08 2:40
Iain Clarke, Warrior Programmer18-Nov-08 2:40 
QuestionA beginner question about winforms in VC++ Pin
Pedram Behroozi16-Nov-08 4:42
Pedram Behroozi16-Nov-08 4:42 
AnswerRe: A beginner question about winforms in VC++ Pin
Mark Salsbery16-Nov-08 6:14
Mark Salsbery16-Nov-08 6:14 
GeneralRe: A beginner question about winforms in VC++ Pin
Pedram Behroozi16-Nov-08 7:42
Pedram Behroozi16-Nov-08 7:42 
AnswerRe: A beginner question about winforms in VC++ Pin
Jijo.Raj16-Nov-08 7:07
Jijo.Raj16-Nov-08 7:07 
GeneralRe: A beginner question about winforms in VC++ Pin
Pedram Behroozi16-Nov-08 7:47
Pedram Behroozi16-Nov-08 7:47 
GeneralRe: A beginner question about winforms in VC++ Pin
Jijo.Raj16-Nov-08 8:13
Jijo.Raj16-Nov-08 8:13 
GeneralRe: A beginner question about winforms in VC++ Pin
N a v a n e e t h16-Nov-08 16:53
N a v a n e e t h16-Nov-08 16:53 
GeneralRe: A beginner question about winforms in VC++ Pin
Pedram Behroozi16-Nov-08 22:02
Pedram Behroozi16-Nov-08 22:02 
QuestionCEdit Control Pin
john563215-Nov-08 21:04
john563215-Nov-08 21:04 
AnswerRe: CEdit Control Pin
Garth J Lancaster15-Nov-08 22:47
professionalGarth J Lancaster15-Nov-08 22:47 
QuestionRe: CEdit Control Pin
CPallini15-Nov-08 23:01
mveCPallini15-Nov-08 23:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.