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? -
-
class graf
-
{
-
-
struct edge
-
{
-
int v, w;
-
edge(int v = -1, int w = -1) : v(v), w(w) {}
-
};
-
-
struct node
-
{
-
int v; node* next;
-
node(int x, node* t) {v = x; next = t; }
-
};
-
-
typedef node* link;
-
vector <link> adj;
-
-
-
-
public:
-
graf(int V) : adj(V) {adj.assign(V,0);}
-
int insert(edge e)
-
{
-
int v = e.v, w=e.w;
-
adj[v] = new node(w, adj[v]);
-
adj[w] = new node(v, adj[w]);
-
}
-
void remove(edge e);
-
bool edge(int v,int w) const;
-
class adjIterator;
-
friend class adjIterator;
-
};
2 9423 boxfish 469
Recognized Expert Contributor
Do you have - #include <vector>
-
using namespace std;
and the top of your header file?
Do you have - #include <vector>
-
using namespace std;
and the top of your header file?
I forgot about it... Thank you again!
Sign in to post your reply or Sign up for a free account.
Similar topics |
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:
|
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,...
|
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) {
|
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
|
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...
| |
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...
|
by: Andreas.Burman |
last post by:
Hi
What is the best way to implement a undirected weighted graph ADT in
javascript?
|
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...
|
by: Man4ish |
last post by:
namespace ve/////////////////ve.h
{
struct VertexProperties
{
std::size_t index;
boost::default_color_type color;
};
}
///////////////////////////////////////////////////////////////////////////////////////////////////
namespace ed///////////////////////ed.h
|
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...
|
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,...
| |
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...
|
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,...
|
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...
|
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...
|
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...
|
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
| |
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...
| |