Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > data structure for graph

Reply
Thread Tools

data structure for graph

 
 
Sameer
Guest
Posts: n/a
 
      09-15-2003
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.


 
Reply With Quote
 
 
 
 
Sameer
Guest
Posts: n/a
 
      09-15-2003

"Sameer" <> wrote in message
news:bk49r7$oln04$...
> 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


 
Reply With Quote
 
 
 
 
Ivan Vecerina
Guest
Posts: n/a
 
      09-15-2003
Hi Sameer,
"Sameer" <> wrote in message
news:bk49us$nsql6$...
....
| > 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


 
Reply With Quote
 
Malcolm
Guest
Posts: n/a
 
      09-15-2003

"Sameer" <> 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?


 
Reply With Quote
 
Barry Schwarz
Guest
Posts: n/a
 
      09-15-2003
On Mon, 15 Sep 2003 17:36:50 +0530, "Sameer" <>
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>>
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Boost.Graph] graph.vertices property creates new objects George Sakkis Python 1 01-29-2007 11:09 PM
Graph Data structure to storing components in spice netlist.. Jonny C++ 2 05-02-2006 08:59 AM
Using XSLT and XPath for graph data structure processing? Ramon M. Felciano XML 6 01-15-2004 12:43 AM
Using XSLT and XPath for graph data structure processing? Ramon M. Felciano XML 1 01-12-2004 08:47 AM
GD::Graph: "mixed" graph doesn't recognize "area" graph type Emilio Mayorga Perl Misc 6 10-08-2003 02:14 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57