Connecting Tech Pros Worldwide Help | Site Map

Problem with a conceptual graph

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 04:38 PM
Daniel Ladd
Guest
 
Posts: n/a
Default 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/

  #2  
Old July 22nd, 2005, 04:39 PM
puppet_sock@hotmail.com
Guest
 
Posts: n/a
Default Re: Problem with a conceptual graph

"Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message news:<opsbd9hjsdxblvrs@localhost.localdomain>...[color=blue]
> Hi,
> I have a problem with a conceptual graph in c++.
> I have a list of structures like this:
> typedef struct Conceptual
> {[/color]
char* Name;//Rappresenta la parola da mettere nel grafo[color=blue]
> Conceptual* Next;
> Conceptual()
> {Next=NULL;
> Name=NULL;
> }
> };[/color]

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
  #3  
Old July 22nd, 2005, 04:40 PM
Daniele
Guest
 
Posts: n/a
Default Re: Problem with a conceptual graph

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, <puppet_sock@hotmail.com> wrote:
[color=blue]
> "Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message
> news:<opsbd9hjsdxblvrs@localhost.localdomain>...[color=green]
>> Hi,
>> I have a problem with a conceptual graph in c++.
>> I have a list of structures like this:
>> typedef struct Conceptual
>> {[/color]
> char* Name;//Rappresenta la parola da mettere nel grafo[color=green]
>> Conceptual* Next;
>> Conceptual()
>> {Next=NULL;
>> Name=NULL;
>> }
>> };[/color]
>
> 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[/color]



--
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/
  #4  
Old July 22nd, 2005, 04:40 PM
Karl Heinz Buchegger
Guest
 
Posts: n/a
Default Re: Problem with a conceptual graph

Daniele wrote:[color=blue]
>
> Because I never made one and it's the only way that I know to manage a
> list of structures.[/color]

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;
}
[color=blue]
> Can you help me?[/color]

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
kbuchegg@gascad.at
  #5  
Old July 22nd, 2005, 04:41 PM
Brian McGuinness
Guest
 
Posts: n/a
Default Re: Problem with a conceptual graph

"Daniel Ladd" <se_lachiedi@te_la_dico.it> wrote in message news:<opsbd9hjsdxblvrs@localhost.localdomain>...[color=blue]
> 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
>
> --[/color]

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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.