473,326 Members | 2,173 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,326 software developers and data experts.

implementing a graph

bucketbot
Can anyone explain how to code a graph based on a priority queue? As in, what would I need to do in order to successfully implement a graph? thanks
May 19 '07 #1
4 2493
Can anyone explain how to code a graph based on a priority queue? As in, what would I need to do in order to successfully implement a graph? thanks
i forgot to mention that the graph needs to be an adjacency list, and that it should be implemented with an ArrayList
May 19 '07 #2
JosAH
11,448 Expert 8TB
i forgot to mention that the graph needs to be an adjacency list, and that it should be implemented with an ArrayList
I'm sorry, I think I don't understand your question. What have priority queues
to do with graphs? Do you have to build your adjacency matrix yourself or is
that given already? What do you want to do with that graph?

kind regards,

Jos
May 20 '07 #3
I'm sorry, I think I don't understand your question. What have priority queues
to do with graphs? Do you have to build your adjacency matrix yourself or is
that given already? What do you want to do with that graph?

kind regards,

Jos

we constructed a min-heap based priority queue, and now we have to design a graph (for use with Dijkstras algorithm) using that PQ. I just don't understand how to construct the graph. So far, I have a Graph class, a Vertex class, and an Edge class. If my vertex class is simply a name and an array of incident edges, then what is my Edge class?

the end product is suppose to be something that reads in input (in this case, a sort of map), and it has to determine which path has the shortest distance or shortest time to travel.

thanks
May 21 '07 #4
prometheuzz
197 Expert 100+
...

I just don't understand how to construct the graph. So far, I have a Graph class, a Vertex class, and an Edge class. If my vertex class is simply a name and an array of incident edges, then what is my Edge class?

...
An Edge class isn't necessary. Just use a java.util.List in your Vertex class that holds references to the neighbouring Vertices.
And your Graph class has a java.util.List with Vertex objects of course.

Another approach is to use an implementation of a java.util.Map<Key, Value>,where the key is a (unique) Vertex and the value is a java.util.List containing the Vertex's neighbours.

Good luck.
May 22 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Lilith | last post by:
Is there a python module somewhere (been searching today, no luck) which has efficiently coded various graph-handling routines, such as finding the shortest path through a graph, or the set of all...
1
by: entropy123 | last post by:
Hey all, In an effort to solve a sticky - for me - problem I've picked up Sedgewick's 'Algorithm's in C'. I've tried working through the first few problems but am a little stumped when he refers...
4
by: phl | last post by:
hi, My question is: 1. To avoid possible memory leaks, when you use this pattern, after you have dealth with the unmanaged resources and before you take your object off the finalize queue,...
2
by: sriniwas | last post by:
Hi Frnd's, m using prefuse visulation,it's have one display class and this class have one saveImage(outPutStream, String jpg,double size);. now graph is converting ia jpg image properly.now my...
4
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; }...
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...
7
thatos
by: thatos | last post by:
Here is the EdgeList class class Graph { protected int numvertices; protected int numedges; protected boolean directed; protected EdgeList adjlist ; // Constructors
2
by: Bart Kastermans | last post by:
Summary: can't verify big O claim, how to properly time this? On Jun 15, 2:34 pm, "Terry Reedy" <tjre...@udel.eduwrote: Thanks for the idea. I would expect the separation to lead to somewhat...
0
by: eureka2050 | last post by:
Hi all, I am creating a radar chart containing 2 plots using jpgraph. My code is as follows:- include ("./jpgraph/src/jpgraph.php"); include ("./jpgraph/src/jpgraph_radar.php"); //...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.