473,624 Members | 2,238 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

implementing a graph

bucketbot
9 New Member
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 2505
bucketbot
9 New Member
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 Recognized Expert MVP
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
bucketbot
9 New Member
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 Recognized Expert New Member
...

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<K ey, 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
2893
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 paths through a graph? I'm not a compsci-educated person, so coding my own would be less parsimonious. Thanks for any suggestions! D
1
4381
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 to #include "Graph.h" in the header file of the first program. The style he uses to make his declarations is a little unfamiliar to me, but here is my best guess at a "Graph.h" header file:
4
3322
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, how are you sure that your managed object resources are completely freed up of resources it's might be using? In my case below I have a private bool variable. Are there any other managed resource that you might need to explicitly free up in
2
4127
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 problem is tht,If graph is to large if it going out of screen thn ,i m getting jpg image on screen disply graph,m not getting the image of tht graph which going out of screen. this is my code This is my code
4
2545
by: Man4ish | last post by:
namespace ve/////////////////ve.h { struct VertexProperties { std::size_t index; boost::default_color_type color; }; } /////////////////////////////////////////////////////////////////////////////////////////////////// namespace ed///////////////////////ed.h
2
2303
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 <boost/graph/adjacency_list.hpp> #include <boost/tuple/tuple.hpp> #include <set> using namespace std;
7
9203
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
2241
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 more code, but all the "checking the root" code would be separated out in the tree class. The node class would be very smooth. I'll try this when I have
0
3470
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"); // Create the basic radar graph $graph = new RadarGraph(700,500,"auto");
0
8233
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8170
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8619
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8334
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8474
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7158
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2604
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.