473,394 Members | 1,843 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,394 software developers and data experts.

any info on graphs algorithms examples ?

I am looking onto some C examples about graphs: implementation with
adjacent matriz or with linked list, and how can I visit the vertex.

Any sample code ???

Tna
Johnny
Jun 19 '06 #1
4 2191
johnny wrote:
I am looking onto some C examples about graphs: implementation with
adjacent matriz or with linked list, and how can I visit the vertex.

Any sample code ???


Algorithms in C Parts 1-5 by Robert Sedgewick, Part 5 consists of its
own volume dedicated to graphing algorithms and their implementations
in C.

You could try searching google as well.

Robert Gamble

Jun 19 '06 #2
Robert Gamble wrote:
johnny wrote:
I am looking onto some C examples about graphs: implementation with
adjacent matriz or with linked list, and how can I visit the vertex.

Any sample code ???


Algorithms in C Parts 1-5 by Robert Sedgewick, Part 5 consists of its
own volume dedicated to graphing algorithms and their implementations
in C.


In my copy it is chapters 29 thru 34. ISBN 0-201-51425-7, 1990.

--
"I don't know where bin Laden is. I have no idea and really
don't care. It's not that important." - G.W. Bush, 2002-03-13
"No, we've had no evidence that Saddam Hussein was involved
with September the 11th." - George Walker Bush 2003-09-17
Jun 19 '06 #3
CBFalconer wrote:
Robert Gamble wrote:
johnny wrote:
I am looking onto some C examples about graphs: implementation with
adjacent matriz or with linked list, and how can I visit the vertex.

Any sample code ???


Algorithms in C Parts 1-5 by Robert Sedgewick, Part 5 consists of its
own volume dedicated to graphing algorithms and their implementations
in C.


In my copy it is chapters 29 thru 34. ISBN 0-201-51425-7, 1990.


I was referring to the 3rd edition, I guess I should have mentioned
that.

Robert Gamble

Jun 19 '06 #4

"johnny" <a@a.com> wrote in message
news:e7**********@nsnmrro2-gest.nuria.telefonica-data.net...
I am looking onto some C examples about graphs: implementation with
adjacent matriz or with linked list, and how can I visit the vertex.

Any sample code ???

You really want comp.programming.

In C, it is easy to build complex data structures like graphs with
structures containing pointers.

eg

typedef struct Vertex_tag
{
int Nneighbours;
struct Vertex_tag **neighbour;
void *userdata;
} Vertex;

The slightly unusual Vertex_tag construction is to get round a problem with
recursive typedefs. The neightbour member is a list of pointers, allocated
with malloc(), and Nneighbours is self-explanatory.

The other way would be to have an adjaceny matrix

int *adjmatrix = malloc(N * N);

for(i=0;i<N;i++)
for(j=0;j<N;j++)
if(adjacent(i,j))
adjmatrix[i*N+j] = 1;
else
adjmatrix[i*N+j] = 0;

This suffers from the problem that C syntax for 2 d arrays is very difficult
to use, hence we are simply doing the array indexing by hand.

Which method you use won't be dictated by language considerations, however,
but what makes sense in terms of the particular algorithm you are trying to
implement.
--
Buy my book 12 Common Atheist Arguments (refuted)
$1.25 download or $7.20 paper, available www.lulu.com/bgy1mm
Jun 19 '06 #5

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

Similar topics

7
by: Florian Lindner | last post by:
Hello, I'm looking for a program or python library to draw graphs. They should look like the that: /--------\ /--------\ | Node A | ------ belongs to ----> | Node B |...
3
by: mscir | last post by:
I'm trying to find thorough documentation for creating graphs using serverside Excel from ASP. Any book recommendations? A well-documented COM wrapper would be nice if it allowed us to create...
2
by: sid | last post by:
Hi, i was wondering how to generate maps (simple graphs) using XML. Its for a project which requires the use of web services. I have to use algorithms to traverse the graph. I would really...
0
by: Gerry Abbott | last post by:
Hi All, I have a series of parameters for which there is parameter values over several years. I need to graph each parameter on a graph and put them into a report. I also need to allow the user to...
1
by: pocm | last post by:
Hi all, I'm at work and I don't have a copy of C Unleashed here with me, I have it at home. However, I'd like someone to confirm me that the Graph code of C Unleashed is not for Directed Graphs....
7
by: Anders Borum | last post by:
Hello! I'm starting to dive into algorithms in general (sorting, trees etc.) and am currently reading a book from Robert Sedgewick called "Algorithms in C++, 3rd. Edition" and would like other...
2
by: srinivasreddypn | last post by:
Hi, Hello experts! please let me know how to develop graphs in flash by calling XML's data into flash. If you have any examples of graphs in flash using xml data, please provide it to me. Any...
53
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming...
15
by: Eric Lindsay | last post by:
I need to include some simple (sparkline style) graphs in a web page that will have a liquid layout. Some viewers will be changing the font size to suit their display (sizes range from 320 to 2560...
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: 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?
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.