By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,386 Members | 1,777 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,386 IT Pros & Developers. It's quick & easy.

data structure for graph

P: n/a
Hello,

A data structure for the implementation of graph can be

struct node
{
int index;
struct node *next;
};

struct adjnode // node adjacent to node
{
int adjindex;
struct node *next;
struct adjnode *next;
};
input file is

node1 adjnode1 adjnode3
node2 adjnode1 adjnode4
node3 adjnode1 adjnode4
node3 adjnode2 adjnode3

such that 1234 forms a quadrilateral.

How can I populate all the data in one file read...
Kindly reply,
Regards,
Sameer.
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a

"Sameer" <ia*******@hotmail.com> wrote in message
news:bk************@ID-160782.news.uni-berlin.de...
Hello,

A data structure for the implementation of graph can be

struct node
{
int index;
struct node *next;
};

struct adjnode // node adjacent to node
{
int adjindex;
struct node *next;
struct adjnode *next;
};
input file is

node1 adjnode1 adjnode3
node2 adjnode1 adjnode4
node3 adjnode1 adjnode4
node3 adjnode2 adjnode3

such that 1234 forms a quadrilateral.

How can I populate all the data in one file read...
Kindly reply,
Regards,
Sameer.

sorry the currect input file is

node1 adjnode2 adjnode3
node2 adjnode1 adjnode4
node3 adjnode1 adjnode4
node4 adjnode2 adjnode3
Nov 13 '05 #2

P: n/a
Hi Sameer,
"Sameer" <ia*******@hotmail.com> wrote in message
news:bk************@ID-160782.news.uni-berlin.de...
....
| > A data structure for the implementation of graph can be
| >
| > struct node
| > {
| > int index;
| > struct node *next;
| > };
| >
| > struct adjnode // node adjacent to node
| > {
| > int adjindex;
| > struct node *next;
| > struct adjnode *next;
| > };
....
| sorry the currect input file is
|
| node1 adjnode2 adjnode3
| node2 adjnode1 adjnode4
| node3 adjnode1 adjnode4
| node4 adjnode2 adjnode3

Unfortunately, your question remains too vague.
There are many kinds of graphs (cyclic/acyclic,
oriented or not, ...), and even more ways
to represent them using different data structures.

From your post, I still do not understand how
struct node and struct adjnode are intended to
be used.

I think you need to tell more about your
goals/constraints/requirements.
Regards,
Ivan
--
http://ivan.vecerina.com
Nov 13 '05 #3

P: n/a

"Sameer" <ia*******@hotmail.com> wrote in message
A data structure for the implementation of graph can be

struct node
{
int index;
struct node *next;
};

struct adjnode // node adjacent to node
{
int adjindex;
struct node *next;
struct adjnode *next;
};
input file is

node1 adjnode1 adjnode3
node2 adjnode1 adjnode4
node3 adjnode1 adjnode4
node3 adjnode2 adjnode3

such that 1234 forms a quadrilateral.

How can I populate all the data in one file read...

If you're only allowed to make one call to a read function, the only thing
you can do is read to a temporary buffer. This doesn't really answer ypur
question.

It looks like each line starts with a terminal node, then contains an
arbitrary number of adjnodes that point to the terminal node, and to another
adjnode.
However what I don't understand is that you seem to have declared 8
adjnodes, yet the maximum index is four. Are you sure that adjnodes don't
actually contain two adjnode pointers?
Nov 13 '05 #4

P: n/a
On Mon, 15 Sep 2003 17:36:50 +0530, "Sameer" <ia*******@hotmail.com>
wrote:
Hello,

A data structure for the implementation of graph can be

struct node
{
int index;
struct node *next;
};

struct adjnode // node adjacent to node
{
int adjindex;
struct node *next;
struct adjnode *next;
};


There can be only one member named next is struct adjnode. Perhaps
you would like to call these two pointer n_next and a_next.

<<Remove the del for email>>
Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.