473,698 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

graph using adjacency list - problem

5 New Member
Here's my code that's supposed to be a basic graph implementation using adjacency lists. It comes straight from R.Sedgewick's "Algorithms in C++".
However "23 - ISO C++ forbids declaration of `vector' with no type ". Why is that?


Expand|Select|Wrap|Line Numbers
  1.  
  2. class graf
  3. {
  4.  
  5.     struct edge
  6. {
  7.        int v, w;
  8.        edge(int v = -1, int w = -1) : v(v), w(w) {}
  9. };
  10.  
  11. struct node
  12.               {
  13.                      int v; node* next;
  14.                      node(int x, node* t) {v = x; next = t; }
  15.               };
  16.  
  17.       typedef node* link;
  18.       vector <link> adj;
  19.  
  20.  
  21.  
  22. public:
  23.              graf(int V) : adj(V) {adj.assign(V,0);}
  24.              int insert(edge e)
  25.              {
  26.                  int v = e.v, w=e.w;
  27.                  adj[v] = new node(w, adj[v]);
  28.                  adj[w] = new node(v, adj[w]);
  29.                  } 
  30.              void remove(edge e);
  31.              bool edge(int v,int w) const;
  32.              class adjIterator;
  33.              friend class adjIterator;
  34. };
Nov 13 '08 #1
2 9423
boxfish
469 Recognized Expert Contributor
Do you have
Expand|Select|Wrap|Line Numbers
  1. #include <vector>
  2. using namespace std;
and the top of your header file?
Nov 13 '08 #2
orzeech
5 New Member
Do you have
Expand|Select|Wrap|Line Numbers
  1. #include <vector>
  2. using namespace std;
and the top of your header file?

I forgot about it... Thank you again!
Nov 13 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
3451
by: Paul Moore | last post by:
I'm trying to check a graph (represented in the usual Python adjacency list format) for loops. This is dead simple - you use a depth-first search, and look out for "back edges" (edges from a vertex "back" to one you've already seen). I already have a DFS algorithm which generates each edge in turn. It's great for what it does, but it ignores back edges. def DFS(graph, start, seen = None): if not seen:
25
3787
by: Magnus Lie Hetland | last post by:
Is there any interest in a (hypothetical) standard graph API (with 'graph' meaning a network, consisting of nodes and edges)? Yes, we have the standard ways of implementing graphs through (e.g.) dicts mapping nodes to neighbor-sets, but if one wants a graph that's implemented in some other way, this may not be the most convenient (or abstract) interface to emulate. It might be nice to have the kind of polymorphic freedom that one has with,...
2
5874
by: Scott Dabot | last post by:
Im trying to print out the order in which the vertexes of a graph are pushed on to the stack then print out the order in which they are popped off the stack. My current approach is void dfs(struct ADJACENCY *G_adj,int v) { int i,u; G_adj->mark=1; visit(v,G_adj); while ((u=next_adj_vertex(v,G_adj))>=0) {
3
2820
by: alice | last post by:
hi all, I am very new to graphs.So can somebody please give me a link to some graphs tutorial as well as their assignment. Thanks, Alice Walls
8
2444
by: Jef Driesen | last post by:
I'm working on an image segmentation algorithm. An essential part of the algorithm is a graph to keep track of the connectivity between regions. At the moment I have a working implementation, but it's not flexible enough anymore and I need something more advanced. I already have a data structure in mind, but I don't know how to implement that nicely in C++. // Main class which holds the lists with // edges and vertices. These lists are...
3
7828
by: Jef Driesen | last post by:
I'm trying to create a graph from an image, where pixel values are regions labels. I have defined my graph to use lists instead of the vectors (because I need to add/remove vertices and edges) and one extra property for the vertex (the region label): typedef boost::adjacency_list< boost::listS, // Adjacency list boost::listS, // Vertex list boost::undirectedS, // Undirected graph unsigned int, // Vertex property...
11
3038
by: Andreas.Burman | last post by:
Hi What is the best way to implement a undirected weighted graph ADT in javascript?
10
1902
by: andrea | last post by:
I'm studying some graphs algorithm (minumum spanning tree, breath search first topological sort etc etc...) and to understand better the theory I'm implementing them with python... I made my own graph class, the constructor is simply this: class graph: "in forma di matrice e' una matrice normale, in forma di lista uso un dizionario" def __init__(self,nodes,edges,dir=False,weight=): # inizializzatore dell'oggetto, di default in forma di...
4
2551
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; } /////////////////////////////////////////////////////////////////////////////////////////////////// namespace ed///////////////////////ed.h
0
8683
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8610
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8902
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7740
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6528
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.