All pastes #220950 Raw Edit

Mine

public text v1 · immutable
#220950 ·published 2006-10-25 12:46 UTC
rendered paste body
#include "digraph.h"
#include <iostream>

digraph::digraph()
{
	nextNode = graphNodes.begin();
}

int digraph::getSize()
{
	return graphNodes.size();
}

void digraph::addNode(int n, int a)
{
	node *foundNode = NULL;
	node *adjacentNode = NULL;
	vector<node>::iterator i;

	for(i = graphNodes.begin(); i != graphNodes.end(); i++)
	{
		if(i->getKey() == n)
		{
			*foundNode = *i;
		}
	}

	if(foundNode == NULL)
	{
		foundNode = new node(n);

	}

	for(i = graphNodes.begin(); i != graphNodes.end(); i++)
	{
		if(i->getKey() == n)
		{
			*adjacentNode = *i;
		}
	}

	if(adjacentNode == NULL)
	{
		adjacentNode = new node(a);
	}

	graphNodes.push_back(*foundNode);

}