General Graph Question

Hello all,
I am interested in learning about graphs and shortest paths in Java, particularly for problems like the Word Ladder from SIGCSE 2001. I have read up about graphs in a couple Algorithm / Java books, but they mostly describe the structures and behaviors of graphs and algorithms to traverse graphs (BFS, DFS, etc), but I'm having a difficult time understanding how to "construct" a graph.
For example, if one was interested in finding the shortest path between two five letter words in a graph (start vertex, end vertex), you could read in all five letter words that are to be tested into an unordered Array. After the words are all stored in the unordered array, you could BFS the unordered array which would take the starting vertex (a word from the unordered array), add it to a queue, mark that vertex as visited, remove it from the queue, and then find the next word that only has a one letter difference than the last, add that to the queue, mark it as visited, search for the next word that's only one letter away from the second in the unordered array, etc?
money <----- Starting vertex
honey
etc
etc
etc
(ending vertex)
I don't know if I did a good job of explaining what I'm asking... Generally what it boils down to is that I'm having a difficult time understanding the actual concept of graphs and how they are constructed, assuming you have a bunch of five letter words (Word Ladder) and you need to find the shortest path between first word and the last word you supply.
I've tried searching around the net for a good example of graphs actually being constructed and searched through in Java, but something isn't clicking with me. Is there anybody that could assist in helping me understand this concept?
Any help would be appreciated, and I apologize in advance if I'm not supposed to post general questions in this forum.

Building the graph is the lesser of the tedious jobs you have to do: every word represents a node. An edge from node A to node B occurs if word A differs in only one letter with word B. If you represent the graph as nodes having an outgoing edge list then B contains A in its list only if A contains B in its list, i.e. the graph isn't directed. e.g. "honey" is one 'hop' away from "money" because "money" is one 'hop' away from "honey"; the 'hop' is the edge. Once you have that complete graph you can play with shortest path algorithms etc.
kind regards,
Jos
ps. personally I'd build a BitSet per node indicating which other node(s) are one hop away from that node. The words can be simply stored in a linear array.

Similar Messages

  • General dreamwevaer question

    hello dreamweavers.
    im a newbie going to use dreamweaver from next week and beyond,so id like to ask the following:
    should i design the website in photoshop and then import it into dreamwevaer,in order to code it?
    is dreamwevaer flexible in design point of view,or is it mostly getting finished designs such as headers,footers,flash banners,
    and then building up the site where things so and such.
    thank you.

    Hello Nancy.
    seems like an informative website,i can see it is easy to understand the
    basics.
    Στις 23 Μαρτίου 2012 4:29 π.μ., ο χρήστης Nancy O. <[email protected]>έγραψε:
       Re: general dreamwevaer question  created by Nancy O.<http://forums.adobe.com/people/Nancy+O.>in
    Dreamweaver - View the full discussion<http://forums.adobe.com/message/4283588#4283588

  • Instruments ObjectAlloc Graph question

    Hello,
    I'm in the process of finalizing my iPhone application for release. Right now I'm focused on performance tuning and hunting down memory leaks. I've been using the Instruments application to help find memory leaks and it has been quite wonderful. I was able to successfully fix the few memory leaks reported. I'm relatively new to using instruments and I did have 1 question about the ObjectAlloc instrument:
    In general I've noticed that the CurrentBytes display graph of the ObjectAlloc instrument is always going up. It's not going up rapidly, but just slowly overtime during the use of my application. Even when some of my objects get deallocated it doesn't seem to make the graph go down. This seems wrong to me. The Leaks instrument is not reporting any memory leaks at this time. Why would my ObjectAlloc graph continue to go up? Should I be worried about this? Perhaps I'm doing something wrong or reading the graph wrong?
    Any insight would be greatly appreciated.
    Thank you,
    -Keith

    Thanks for the explanation Mark that is what I suspected but it helps to have it confirmed.
    A second question. I notice that the Net Bytes and #Net are going up over time very slowly. It seems to ramp up at the beginning and then plateau around 8420000 bytes. After playing the game a few times more it may be up to 8430000 bytes or so. Leaks isn't reporting any memory leaks. Any idea what might be going on or how I may be able to go about tracking this down?
    Thank you,
    -Keith

  • Discoverer Desktop Graphing Questions

    I have several questions about the graphing tool in Discoverer Desktop:
    1. I'm bringing in a customer id field which I convert with a to_char in the query from a numeric field. Most of them are 5-digit, but some are 4. I notice in the x-axis the customer id's appear only for the 5 digit id's, and for the 4-digit ones the identifier appears. i.e. if the 5th record has an id of 1508, instead of displaying 1508 it displays 5. Does anyone know how to correct this?
    2. In the y-axis values, is it possible to display more than 5 decimal places? (We're dealing with very small percentages). When I try to enter 6 or higher as the decimal value in Options, it says invalid number.
    3. When I open an existing workbook, it readjusts the y-axis scale to a max of 1, when I've set it to .0001. How I can I make this retain my scale values?
    4. Is it possible to display the y-values in the graph area itself next to the plot points?
    Thanks for any help!!!!

    Hi paul,
    Its a good idea to upgrade from 4i to 10g 4i is no more used by many and their are some issues or bugs with it.The latest version is 11g which has been released 1 week back.If not go with 10g version available.
    1) Do all reports have to be stored on the database to allow them to be accessed by Plus or Viewer? Can only the 10G client version open files from a local hardrive or shared network drive?Yes they have to stored in the database so any ened user can access them from plus or viewer.
    Can only one report be open at any given time with Plus or Viewer? In client it is possible to have 2 reports open at the same time to facilitate easier comparisons.Yes,if the reports are registered as different reports and if the end user has access to both the reports thn he can open and compare it OR if both reports are in same workbook as different sheets than its easy to view or compare.
    NULL values are still showing the word "NULL" even though in Tools Options we have set it to show blank, existing reports are still using the NULL value.It should show blank,might be some problem.In discoverer 10g i think you will not find this issues.
    Hope this helps you.
    Best Wishes,
    kranthi.

  • A few general agent questions

    We've been asked some general questions by our agents that I have been unable to find answers for, (although 4 and 5 are likely working as designed). We are running IPCC Express 7.0(1)SR05_Build504 and these are all phone agents. We do not run the agent desktop client. Any assistance in answering these questions would be greatly appreciated.
    1. TransfertoVM softkey "grayed out" while on a CSQ call. Can it be enabled?
    2. While logged in to CSQ, is there a way to start dialing prior to
    lifting the receiver?
    3. Is it possible to handle more than one CSQ call at a time, e.g. put a call on hold and answer
    another CSQ call.
    4. Upon selecting Agent Login (single-button login), can the agent automatically be put into Ready?
    5. Upon Logout, can the phone be returned to the main screen, rather than getting the manual agent login screen?
    Again, any assistance in answering these questions would be greatly appreciated.
    Thanks,
    Roger

    Hi
    1) Isn't that an IPMA softkey? Never tried it, but whilst it's not in the 'unsupported' list, I wouldn't expect using any IPMA features in conjunction with CAD would get you good results. If it doesn't cause you stuck/ghost calls, I would expect erroneous reports...
    2) Being logged into a CSQ doesn't affect the way the phone works.
    - You can dial the number then either lift the handset or hit dial (for speakerphone)
    - You can press speakerphone or headset then dial
    I guess what you are referring to is if you are using the IP Phone Agent in conjunction with a headset? If you are, then the IPPA usually obscures the 'new call' and 'end call' softkeys that you might use if you leave the headset button lit. I guess this isn't the case, as you refer to lifting the receiver? Unless you have motorized lifters.. If that's what you have, you can try getting users to either :
    - Manage their onhook/offhook state using the headset key as if it was the speakerphone key (i.e. press it to hang up or pickup)
    - Use a headset/phone combination that supports HHC
    - Switch to CAD, or CAD-BE if you can't install PC software for some reason.
    3) No. The system is designed specifically so that this should never happen.
    4) No.
    5) Again, no... you can't customize the BIPPA service... If you use CAD or CAD-BE this wouldn't be an issue.
    Regards
    Aaron
    Please rate helpful posts...

  • Workflow and General Use Questions

    Hello,
    I'll apologize right off the bat for these novice question because I'm sure the information is probably somewhere in the forum, I just haven't been able to find it. I just purchased Aperture after completing the demo as my library is getting too large to manage using standard file folders. I'm now trying to figure out the best practices for workflow and general use before I invest some serious time into importing and keywording all my pictures.
    1) Store files in the there current location, or in the Aperture Library? It seems to me that once they are moved to the Aperture library, you can only access them from within Aperture. I'm thinking I would be better off leaving them in their current location. For one, if I want to quickly grab a picture as an attachment to an email or something it seems easier to grab it from the standard folders. Second (and more important) I do not have room to keep all my pictures on my Macbook, thus most of them are stored on the Time Capsule.
    So... Keeping photos in their current location appears to be the best choice for me even though it adds an additional step every time I bring in new photos from my camera. Does this sound right?
    2) Is there a way to mark the photos that I have uploaded to my website (Smugmug)? Ideally, I would like to badge photos that have already been uploaded so I can quickly recognize them and ensure I'm not duplicating. I've considered using the rating, or keywords to indicate that a photo has been uploaded but both methods have disadvantages.
    3) Any suggestions for general workflow and organization resources (tutorials, books, websites, etc.)? I've looked at the videos on Apple's site but they obviously didn't get that detailed.
    Thanks for the help, sorry for the length.

    I recommend to Manage by Reference with Master image files stored on external hard drives (note that Aperture defaults to a Managed-Library configuration rather than a Referenced-Masters Library). Especially important for iMacs and laptops with a single internal drive. The workflow as described below in an earlier post of mine uses a Referenced-Masters Library.
    I feel pretty strongly that card-to-Aperture or camera-to-Aperture handling of original images puts originals at unnecessary risk. I suggest this workflow, first using the Finder (not Aperture) to copy images from CF card to computer hard drive:
    • Remove the memory card from the camera and insert it into a memory card reader. Faster readers and faster cards are preferable.
    • Finder-copy images from memory card to a labeled folder on the intended permanent Masters location hard drive.
    • Eject memory card.
    • Burn backup hard drive or DVD copies of the original images (optional strongly recommended recommended backup step).
    • Eject backup hard drive(s) or DVDs.
    • From within Aperture, import images from the hard drive folder into Aperture selecting "Store files in their current location." This is called "referenced images." During import is the best time to also add keywords, but that is another discussion.
    • Review pix for completeness (e.g. a 500-pic shoot has 500 valid images showing in Aperture).
    • Reformat memory card in camera, and archive originals off site on hard drives and/or on DVDs.
    Note that the "eject" steps above are important in order to avoid mistakenly working on removable media/backups.
    Also note with a Referenced-Masters Library that use of the "Vault" backup routine backs up the Library only, not the Masters. Masters should be separately backed up, IMO a good thing from a workflow and data security standpoint.
    Max out RAM in your MB and keep the internal drive less than 70% full.
    Good luck!
    -Allen Wicks

  • Line Graph Question: Compare different values thru time ...

    Hi, hope someone can help me I've been looking at examples, but I cant get this to work:
    Here is a link to what the data looks like: http://primolandia.com/line_problem.jpg
    As you can see, I have a table with columns: Team, Date, CriteriaNum1, CriteriaNum2, CriteriaNum3
    One graph per Criteria which compares how each Team did on that Criteria thru time...
    So I want the X axis to have the "Date" and have one line per team showing the value at different times ...
    Any ideas?
    Thank you!!!
    Claudio

    I wish to withdraw this question ... I finally figured out my issue...

  • General BADi question:Call BADi in background job/batch input. Possible?

    Hi out there,
    i'm using thoe following BADi: /SAPSLL/CTRL_SD0C_R3 (Global Trade Service).
    But also, this question is a general question.
    If we are calling on screen the transaction VF01, the BADi is called correctly.
    But unfortunately it seemes that the BADi is NOT called (im not really sure, cause i can't debug the background task) when we are calling a batch input sequence wth f.e. form bdc_transaction VF01 nothing happens.
    Maybe BADi cannot be called in a background task? If it's possible, how could it be monitored. Thare isw no spool entry or anything like that!
    Any answer can help.
    Thank you in advance!
    Regards,
    Timo
    Edited by: Timo Ehl on Apr 14, 2009 7:27 PM

    Hi,
    generally BADIs are called in background mode. You can use the following trick to debug your BADI. You just need to create an infinite loop in your BADI implementation. Something like this.
    DATA: l_a TYPE c.
    WHILE l_a IS INITIAL.
    ENDWHILE.
    Obviously when your BADI is called in background mode then program will get into infinite loop. You can easily connect and debug running programs from transaction SM50. You need to select your background process and go to Program/Session -> Program -> Debugging. You will jump directly into your BADI methos with infinite loop. Then you will just set value to l_a and you will start debugging your BADI. If you can not find any process then your BADI is not called in background mode.
    Cheers

  • Specific Excel graph question for Indesign

    Hello,
    I have a question about how to use an image generated on Excel for mac for Adobe Indesign CC. I have browsed the forums here and googled but I'm not finding solutions for my specific question (so please bear with me, thanks). I have a report for work that requires a lot of bar graphs. The graphs are all done on Excel for mac 2011. I have tried two different ways of importing it into InDesign (also for mac) - 1) saving the graph as a PDF and then placing into InDesign, and 2) copying and pasting the Excel graph into Illustrator and then saving it as an ai file. In both cases, the ai file looks a bit better but the fonts seem a bit jarbled/compacted once I place it into InDesign. The font I use is Times New Roman. Also, since my report is laid out in a 2-column format, I need a chart to fit a space that is approximately 3 inches by 3.5 inches. Whenever I import the image, it’s significantly larger so I place it to fit the 3x3.5 inch space proportionally. When that happens, the fonts don't look quite right on the screen. I need to ensure that the chart looks sufficient once it’s printed on paper. I only recently began learning InDesign (self-taught) so your advise is appreciated.

    First, the preview may be at a lower quality, so see how it looks with View > Display Performance > High Quality Display set. Second, ID always displays some sort of preview on screen, but uses the actual image data for output, so export a page to PDF and print it to judge the quality.

  • 3D graph question

    Hi everyone,
    I have 2 questions concerning the 3D graph.
    1°) I can’t find in the property node how to position the view as XY (it’s possible to do it right clicking on the graph, then  CWGraph3D,….). Is there a way to set it throw the property node?
    2°) In the color map editor (see print screen under graph) the figures don’t stay as I have put them although I press on “ok” for saving
    Any help would be great,
    Thanks,
    User
    Attachments:
    Forum graph 3D.vi ‏36 KB

    Hello User_1979,
    Thanks for posting on National Instruments forum.
    There is a property node to change programmatically the ViewMode:
    About your second question, you should be able to set your value then click OK and then click Apply on the Property page. I'm in LabVIEW 2010 and I don't have any problem.
    Benjamin R.
    R&D Software Development Manager
    http://www.fluigent.com/

  • A general OOP question

    Hi
    I have a general OOP design question, and am wondering if someone could relate an answer to the following design?
    I have a class called MediaFolderImport(); - it's designed to build a window with various editing tools in it.
    Within it's constructor, I'm calling a bunch of functions to build the window...
       createTitle();
       createInstructions();
       createToolPanel();
       createDataGrid ();
       createOpen();
       createSave();
    In my document class, I instantiate it...
    public var File_Folder_Import:MediaFolderImport=new MediaFolderImport();
    and then...
    addChild(File_Folder_Import);
    Voila! - the window appears. I WAS very proud of myself.
    Now I want to access something inside the window.  Specifically, there's a radio button that was created in createToolPanel(); - I want to update it to be selected or not selected when I receieve the user's preference from an xml settings file at start up (xml is loaded into the doc class).
    General question:
    What is the best practice, smart way to have designed this?
    - call createToolPanel(); from the doc class instead of within MediaFolderImport();, and somehow (magically) have access to the radio button?
    - leave the design as is, but add some sort of listener within MediaFolderImport that listens for changes to the xml in the doc class, and updates accordingly?
    - do it the way I'm trying to, ie try to access the radio button directly from the doc class (which isn't working):
    File_Folder_Import.myRadioButton.selected = true;
    - a better way someone can briefly explain the concept of?
    Another way to explain my design is...
    - a bunch of different windows, each created by a different class
    - xml file loads preferences, which need to be applied to different tools (radio buttons, check boxes, text fields etc) in the different windows
    I read a lot of posts that talk about how public vars are mostly bad practice.  So if you are making your class vars private, what is the best way to do the kind of inter-class communicating I'm talking about here?
    I think someone throwing light on this will help me solidify my understanding of OOP.
    Thank you for your time and help.

    You're already very used to using properties for the built-in AS classes and that's the best practice means of configuring your class. It's a "state" that you want to simply expose. The get/set method moccamaximum mentioned is the ideal route.
    The main reason you want to use get/set functions is validation. You want your class to act properly if you send an invalid value. Especially if anyone else besides yourself is going to use the class. Plan for the worst.
    The general concept is, make a private variable for any 'state' you want to remember using an underscore in the variable name to easily identify it as a private var, then make get/set functions with the same name with any required validation without the underscore.
    e.g.
    package
         public class MyClass
              // property called 'mode' to track something with an int
               private var _mode:int = 0;
              public function MyClass() {} // empty constructor
              // get (type enforced)
              public function get mode():int { return mode; }
              // set, requiring a value
              public function set isChecked(modeVal:int):void
                   // if no value is sent, ignore
                   if (!modeVal) { return; }
                   _mode = modeVal;
    Your validation will go a long way to easily debugging your classes as they grow in size. Eventually they should throw exceptions and errors if they're not valid. Then you will be best practice. Do note that if your validation requires quite a bit of logic it's common to upgrade the property to a public method. get/set should be reserved for simple properties.

  • Graph question

    hi, I have to do this project for a class, i dont want to know how to do it, just if someone can help point me in the right direction to get me started.
    Im supposed to take an undirected graph and construct an adjacency list representation of the graph.
    My question is,
    first, i am unclear on the deffinition of an undirected vs a directed graph.
    Second, what is the best way to construct this structure? Do I actraly create a graph object or use a linked list im just a little confused.
    Thanks for the help
    _stevebiks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    A undirected graph is one where the connections between nodes have no specific direction. They're not one-way streets, they're two-way streets.
    An adjacency list is a list of all node-pairs which are directly connected (they're neighbours in the graph). You can have a NodePair class to represent them. What actual data structure you use to hold them should be an implementation detail hidden in a class say AdjacencyList. You can start using an ArrayList but that shouldn't be known from the outside. The functionality of AdjacencyList depends on what you want to use it for but a minimum would be an add method and a way to iterate through all stored NodePair objects.

  • Best Font for Subtitles? and other General Subtitling questions?

    I've never had to use subtitles, until my current project, so I am looking for some general advice and suggestions.
    I will be using PPCS3 (on XPpro) as the subtitles (as in the kind that translate a foreign language) will be permanent.
    So here are my questions:
    1. What is the best font and or what is the most standard font for subtitles? (Font size and other characteristics may be worth mentioning here too.)
    2. Is it possible to have an outline around the text as opposed to shadow?
    3. What are some general rules of thumb for subtitles that apply to broadcast and cinematic productions?
    Thank you.

    See also:
    FAQ:Why are my titles blurry/wrong?
    Cheers
    Eddie
    PremiereProPedia   (
    RSS feed)
    - Over 300 frequently answered questions
    - Over 250 free tutorials
    - Maintained by editors like
    you
    Forum FAQ

  • Writing games for US wireless carriers - general newbie question

    I am a newbie to kvm and j2me so excuse me if these question are very basic or if i'm asking the wrong questions.
    I have been asked to quickly research writing games in java for US wireless carriers. Ideally I'd like to pick a carrier (e.g. Verizonwireless) and find out more about writing for them. How should I go about researching this?
    My research so far has found:
    General j2me info:
    I did some initial searching in the forum and found that the following link will give me a basic guide to j2me:
    http://access1.sun.com/SRDs/access1_srds.html.
    If I look at the documentation for -
    - Java 2 Micro Edition (J2ME)
    - Mobile Information Device Profile 1.0.1 (MIDP)
    Is this still the best place to look at online?
    Specific wireless carrier info:
    I had no luck finding where I should look for information on specific
    wireless carriers. Any suggestions? Also am I approaching this the right way or should I be looking at the specific java enabled mobile phones rather than the wireless carrier? Or is it a combination of the two?
    Thanks for any help.

    If the games are going to be networked then you should find out what type of network the carrier has (TDMA,CDMA,GSM with or without GPRS, etc. what bandwidths.... WAP or I-Mode). Regardless, you should be also concerned with what are the phones available on the carrier and what is their Java support.
    shmoove

  • Some general photo questions

    I will be undertaking a major project soon that involves scanning all (and I mean every single one) of my family's photographs so that we have digital copies in case something bad happens to the originals. I plan on using iPhoto to store and catalog the photos. But my question is, when I scan the photos, what file format should I use? My scanner (HP Scanjet 3970) can scan to jpeg, tiff, tiff (compressed), bmp, and gif. which of those should I use? Also, I read somewhere that tiff for macs are different from tiff in windows. Is this true?
    Also, what resolution is optimal for keeping an archive of photos? File size is not really an issue since I'll be using an external hard drive that's plenty big.

    baldrambutan
    what file format should I use? My scanner (HP Scanjet 3970) can scan to jpeg, tiff, tiff (compressed), bmp, and gif. which of those should I use?
    iPhoto will handle any of those formats. My suggestion for maximum compatibility is to choose between tiff (uncompressed) and jpeg. Why? they're pretty universal, regardless of computer. As to choosing between them? Well jpeg is a lossy compressed format, tiff isn't. The files sizes are huge with tiff, quite acceptable with jpeg. How much editing will you do? IF not much, then there is little re-saving and jpeg will be absolutely fine.
    http://en.wikipedia.org/wiki/TaggedImage_FileFormat
    http://en.wikipedia.org/wiki/JPEG
    Also, I read somewhere that tiff for macs are different from tiff in windows. Is this true?
    Not that I know of.
    Also, what resolution is optimal for keeping an archive of photos
    The general rule of thumb is 300 dpi is what's required for printing. Screen images require less.
    Regards
    TD

Maybe you are looking for

  • Just one partner profile for SAP XI?!

    Hi, well i have some thoughts concerning configuring the partner profile on sender side. I have different systems to which e.g. IDocs will be send to. Therefore i was thinking to set one partner profile for each connected system. But on the other han

  • Get resolution out of PDF page?

    I have a PDF document that is created by creating NSImages with size in 72dpi pts, each has a single representation which is measured in pixels. I then put these images into PDFPages with initWithImage, and then save the document. When I open the doc

  • Problem configurin​g WSN network in MAX

    HI, I am facing this problem suddenly in using my NI 9792 gateway .The module is getting detected in MAX  It is that I am not able to find the Node option under devices and interfaces of the gateway in MAX. I am using LV2010 and NI WSN 1.2. Correspo

  • Itunes do not support manual digital photo addition.

    Dear All, I have tried to add audio and video files manually in my ipod classic 160GB and it works but there are no option in itunes to add digital photo manually except sync. Therefore are there any way by which I can add digital photo to itunes man

  • Failed Install of Captivate 5.0.2.630 Patch

    I just tried to install the latest update for Cp5 announced this morning. This is the patch to upgrade Cp5 to 5.0.2.630. However, the install fails with this error message: On the off chance that maybe the install was failing because I was running a