473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem with a conceptual graph


Hi,
I have a problem with a conceptual graph in c++.
I have a oist of structures like this:
typedef struct Conceptual
{ char* Name;//Rappresenta la parola da mettere nel grafo
Conceptual* Next;
Conceptual()
{Next=NULL;
Name=NULL;
}
};
If I have a word that it's connected to one or more other words which is
the best choice to define the connections? (I can't know the number of
connectios that there are from a word to the others.)
I have think to create a univocal variable for every word and to create a
dynamic matrix of connections.
There is another way, like, for example create some kind of pointer that,
inside the list of structures, point inside the list at all the words
which that word is connected?

Grazie
Daniele

--
--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 '05 #1
4 1720
"Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message news:<op**************@localhost.localdomain>...
Hi,
I have a problem with a conceptual graph in c++.
I have a list of structures like this:
typedef struct Conceptual
{ char* Name;//Rappresenta la parola da mettere nel grafo Conceptual* Next;
Conceptual()
{Next=NULL;
Name=NULL;
}
};


Okay, first, why use "typedef" here? Why not make a class?

class Conceptual
{
public:
Conceptual()
{Next=NULL;
Name=NULL;
}
private:
Conceptual* Next;
char* Name;//Rappresenta la parola da mettere nel grafo
};

Next, you seem to be making a linked list. Why not use the
list in the standard library?
Socks
Jul 22 '05 #2
Because I never made one and it's the only way that I know to manage a
list of structures.
Can you help me?
Daniele
On 19 Jul 2004 15:02:41 -0700, <pu*********@hotmail.com> wrote:
"Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message
news:<op**************@localhost.localdomain>...
Hi,
I have a problem with a conceptual graph in c++.
I have a list of structures like this:
typedef struct Conceptual
{

char* Name;//Rappresenta la parola da mettere nel grafo
Conceptual* Next;
Conceptual()
{Next=NULL;
Name=NULL;
}
};


Okay, first, why use "typedef" here? Why not make a class?

class Conceptual
{
public:
Conceptual()
{Next=NULL;
Name=NULL;
}
private:
Conceptual* Next;
char* Name;//Rappresenta la parola da mettere nel grafo
};

Next, you seem to be making a linked list. Why not use the
list in the standard library?
Socks


--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
Jul 22 '05 #3
Daniele wrote:

Because I never made one and it's the only way that I know to manage a
list of structures.
The point is: You don't need to make one. It has already been done
for you, you just need to use it (Same for string management)

#include <iostream>
#include <list>
#include <string>

using namespace std;

struct Conceptual
{
Conceptual( const std::string& Name_ ) : Name( Name_ ) {}
std::string Name;
};

int main()
{
list< Conceptual > MyList;

MyList.push_back( Conceptual( "First" ) );
MyList.push_back( Conceptual( "Second" ) );

list< Conceptual >::iterator it;

for( it = MyList.begin(); it != MyList.end(); ++it )
cout << it->Name << "\n";

cout << endl;
}
Can you help me?


You need to buy some literature and work through it.
look eg. at http://ma.rtij.nl/acllc-c++.FAQ.html)
for some recommendations

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #4
"Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message news:<op**************@localhost.localdomain>...
Hi,
I have a problem with a conceptual graph in c++.
I have a oist of structures like this:
typedef struct Conceptual
{ char* Name;//Rappresenta la parola da mettere nel grafo
Conceptual* Next;
Conceptual()
{Next=NULL;
Name=NULL;
}
};
If I have a word that it's connected to one or more other words which is
the best choice to define the connections? (I can't know the number of
connectios that there are from a word to the others.)
I have think to create a univocal variable for every word and to create a
dynamic matrix of connections.
There is another way, like, for example create some kind of pointer that,
inside the list of structures, point inside the list at all the words
which that word is connected?

Grazie
Daniele

--


If I understand this correctly, each node may point to any number of other
nodes, and the maximum number of pointers leading away from any given node
is not known in advance. So what is required is not a simple linked list
but a node with a variable number of pointers. I would be inclined to try
using a vector of pointers, for example:

class Conceptual {
private:
std::string Name;
std::vector<Conceptual *> Next;

public:
Conceptual (std::string N) : Name (N) {}

AddLink (Conceptual *L) {
Next.push_back (L);
}

Traverse (Conceptual *H); // Traverse the tree starting at node H
};

and so on.

--- Brian
Jul 22 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: news | last post by:
This may be a stupid question, but if I don't ask I'll never know ;) Ok, here it goes.... I am writing an application that renders an image in one picturebox and a graph in another. The image...
5
by: Shawn Hamzee | last post by:
Hello All, I am having a problem with Image_Graph on php 5.1.4. I installed the package and all of its dependencies through pear installer without any hitches. Then I started to add some very...
2
by: savas_karaduman | last post by:
I supposed that creating graph with access would be as easy as how I could with Excel. But it seems to me that there is some tricky point here. What i am trying to do and what i got is as follow: ...
12
by: NOO Recursion | last post by:
Hi everyone! I am trying to write a program that will search a 12x12 for a thing called a "blob". A blob in the grid is made up of asterisks. A blob contains at least one asterisk. If an...
3
by: aaragon | last post by:
Hello everyone, I'm trying to run some simple code but for some reason it doesn't work and I've been staring at it for a long time without a single clue of what's going on. This is what happens,...
2
by: paeh | last post by:
what's wrong for this php code. when I run did not display anything in browser.. this is code: <?php include ("C:/Program Files/Apache Software...
2
by: Man4ish | last post by:
I have created Graph object without vertex and edge property.It is working fine. #include <boost/config.hpp> #include <iostream> #include <vector> #include <string> #include...
1
by: Man4ish | last post by:
I am creating a graph using boost library, I am making the network using create_Network function() i am adding the vertices to this graph by creating the object g of class Graph. I am trying to...
8
thatos
by: thatos | last post by:
I am trying to write an program which performs a breath first search on a graph and returns a tree. class Alist{ int x; Alist next; public Alist (){ } public Alist(int x){ this.x =...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.