Breadth-first traversal on a graph.. need help

I need to make a graph, then run a breadth-first traversal on it. Do I simply make an undirected graph first, then implement the traversal?
the graph should be like this:
A - D - G
B - E - H
C - F - I
Message was edited by:
LuckY07
Message was edited by:
LuckY07
null

I just would like to print something to the screen showing it ran, such as the letters. What would be an easy way to do this using the DirectedGraph implementation? tks.
here is my code:
import ADTPackage.*;     //packages needed to make graph.
import GraphPackage.*;
public class graphTraversal
     public static void main(String[] args)
          GraphInterface<String> graph = new DirectedGraph<String>();     //creates graph.
          //adds vertices.
          graph.addVertex("A");
          graph.addVertex("B");
          graph.addVertex("C");
          graph.addVertex("D");
          graph.addVertex("E");
          graph.addVertex("F");
          graph.addVertex("G");
          graph.addVertex("H");
          graph.addVertex("I");
          //adds edges.
          graph.addEdge("A", "B");
          graph.addEdge("A", "D");
          graph.addEdge("A", "E");
          graph.addEdge("D", "G");
          graph.addEdge("D", "G");
          graph.addEdge("G", "H");
          graph.addEdge("H", "I");
          graph.addEdge("I", "F");
          graph.addEdge("F", "C");
          graph.addEdge("C", "B");
          graph.addEdge("B", "E");
          graph.addEdge("E", "H");
          graph.addEdge("E", "F");
          graph.addEdge("F", "H");
          System.out.println("total number of vertices: " + graph.getNumberOfVertices());
          System.out.println("total number of edges: " + graph.getNumberOfEdges());
          graph.getBreadthFirstTraversal("A");
     }     //end main.
}

Similar Messages

  • Breadth First Traversal of a Network

    I am working on a task that reads from file a list of towns and displays their adjacent towns and distances.
    I then have to do a breath first traversal of the network and am encountering problems in my code. Could someone please have a look at my code and see if they can see where I am going wrong.
    Thank you
    import java.awt.event.*;
    import java.awt.*;
    import java.util.Stack;
    import javax.swing.*;
    import javax.swing.border.Border;
    import javax.swing.border.EtchedBorder;
    public class BreadthFirstTraversal extends JFrame implements ActionListener
         private Container c;
         private JPanel pNorth,pCentre,pSouth;
         private JButton btnExit;
         private JScrollPane jsp;
         private JLabel lblDummy;
         private JTextArea display;
         private Border border;
         BreadthFirstTraversal(Vertex vStart)
              c = getContentPane();
              pNorth = new JPanel();
              lblDummy = new JLabel();
              pNorth.add(lblDummy);
              pCentre = new JPanel();
              display = new JTextArea(20,50);
              display.setFont(new Font("Serif",Font.PLAIN,18));
              jsp = new JScrollPane(display);
              border = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
              jsp.setBorder(border);
              pCentre.add(jsp,BorderLayout.CENTER);
              pSouth = new JPanel();
              btnExit = new JButton("Exit");
              btnExit.addActionListener(this);
              pSouth.add(btnExit);
              breadthFirst(vStart);
              c.add(pNorth,BorderLayout.NORTH);
              c.add(pCentre,BorderLayout.CENTER);
              c.add(pSouth,BorderLayout.SOUTH);
         private void breadthFirst(Vertex start)
              lblDummy.setText("Breadth-First Traversal");
              Arc currentArc = new Arc();
              String currentTown;
              List listStart,listRear,listNext;
              listStart=null;listRear=null;listNext=null;
              listStart=new List(start.getTown());//create first entry to queue
              listRear=listStart;//set the rear to point to start of Queue as well
              start.setProcessed(true);//set the town to processed
              while(listStart!=null)//while queue is not empty
                   currentTown=listStart.getTown();//set current town to look at first
                   display.append(" "+listStart.getTown()+"; ");//append town to display text area
                   listStart=listStart.getLink();//leave the queue
                   currentArc=getAdjacentLink(start,currentTown);//get the link to the adjacent towns that need checked
                   //put adjacent towns on stack if not been processed
                   while(currentArc!=null)
                        if(!townIsProcessed(start,currentArc.getTwn()))//it its not processed
                             if(listStart==null)//if queue is empty
                                  listStart=new List(currentArc.getTwn());//create the start of the queue
                                  listRear=listStart;//set the rear to point at start
                             else
                                  //Add to Rear of Queue
                                  listNext=new List(currentArc.getTwn());//create next element to add to queue
                                  listRear.setLink(listNext);//set the rear to point at the new item
                                  listRear=listNext;//set the rear to the new item that was added
                             setProcessed(start, currentArc.getTwn());//set that town to have been processed
                        currentArc=currentArc.getLink();//move to next Arc
              clearStatus(start);//set all prosessed booleans back to false
         public Arc getAdjacentLink(Vertex start, String town)
              Arc link= new Arc();
              while(start!=null)
                   if(start.getTown().compareTo(town)==0)
                        link=start.getAdjacentTowns();
                   start=start.getLink();//move to next vertex
              return link;
         public void clearStatus(Vertex start)
              while(start!=null)
                   start.setProcessed(false);
                   start=start.getLink();
         public void setProcessed(Vertex start, String twn)
              while(start!=null)
                   if(start.getTown().compareTo(twn)==0)
                        start.setProcessed(true);
                   start=start.getLink();
         public boolean townIsProcessed(Vertex start,String town)
              while(start!=null)
                   if(start.getTown().compareTo(town)==0)
                        if(start.isProcessed())
                             return true;
                        else
                             return false;
                   start=start.getLink();
              return false;
         public void actionPerformed(ActionEvent e)
    }There are no errors in the code itself but when I try to run it I am getting the following messages in the console:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
         at java.lang.String.compareTo(Unknown Source)
         at BreadthFirstTraversal.townIsProcessed(BreadthFirstTraversal.java:130)
         at BreadthFirstTraversal.breadthFirst(BreadthFirstTraversal.java:68)
         at BreadthFirstTraversal.<init>(BreadthFirstTraversal.java:39)
         at NetworkMenu.actionPerformed(NetworkMenu.java:161)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.AbstractButton.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
         at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

    It's not necessarily town that's causing the
    NullPointerException. If start is null, then calling
    getTown() on it would throw a NullPointerException.
    If whatever getTown() returned was null, then calling
    compareTo() on it would throw a NullPointerException.
    So there are three places on that line where it could
    be thrown.Wrong and, uh, wrong. The stack trace show that
    if(start.getTown().compareTo(town)==0)causes a NPE in compareTo's code. If start were null, the NPE would
    occur before compareTo could be entered. If getTown() returns
    null then again the error occurs before entering compareTo's code.
    Therefore, start != null and start.getTown() != null and town == null.

  • Breadth First Traversal of a Tree...

    Hi,
    I want to make a program to print every node of a tree in a Breadth First Search (BFS)/Traversal. Since, BFS searches a tree in levels (i.e. 1st the root, then it's Children, then Grand Children etc from left to right), this is where I'm stuck. Here is my TreeNode class:
    class TreeNode {
      Object element;
      TreeNode left;
      TreeNode right;
      public TreeNode(Object o) {
        element = o;
    }Each node has a reference to its Children nodes etc. Here is how my tree looks like. Mine is similar to this: http://www.codeproject.com/KB/vb/SimpleBTree.aspx
    All the lectures I have read in the net are talking about Queue, but my problem is reading the tree in BFS Traversal order. It's almost 4 days I'm trying to solve this probelm, but can't come up with something. Any help is greatly appreciated.
    Here is my Binary Tree class:
    public class BinaryTree {
         private TreeNode root;
         private int size = 0;
         /** Create a default binary tree */
         public BinaryTree() {
         /** Create a binary tree from an array of objects */
        public BinaryTree(Object[] objects) {
          for (int i = 0; i < objects.length; i++)
            insert(objects);
    /** Insert element o into the binary tree
    * Return true if the element is inserted successfully */
    public boolean insert(Object o) {
    if (root == null)
    root = new TreeNode(o); // Create a new root
    else {
    // Locate the parent node
    TreeNode parent = null;
    TreeNode current = root;
    while (current != null)
    if (((Comparable)o).compareTo(current.element) < 0) {
    parent = current;
    current = current.left;
    else if (((Comparable)o).compareTo(current.element) > 0) {
    parent = current;
    current = current.right;
    else
    return false; // Duplicate node not inserted
    // Create the new node and attach it to the parent node
    if (((Comparable)o).compareTo(parent.element) < 0)
    parent.left = new TreeNode(o);
    else
    parent.right = new TreeNode(o);
    size++;
    return true; // Element inserted
    /** Inorder traversal */
    public void inorder() {
    inorder(root);
    /** Inorder traversal from a subtree */
    private void inorder(TreeNode root) {
    if (root == null) return;
    inorder(root.left);
    System.out.print(root.element + " ");
    inorder(root.right);
    /** Postorder traversal */
    public void postorder() {
    postorder(root);
    /** Postorder traversal from a subtree */
    private void postorder(TreeNode root) {
    if (root == null) return;
    postorder(root.left);
    postorder(root.right);
    System.out.print(root.element + " ");
    /** Preorder traversal */
    public void preorder() {
    preorder(root);
    /** Preorder traversal from a subtree */
    private void preorder(TreeNode root) {
    if (root == null) return;
    System.out.print(root.element + " ");
    preorder(root.left);
    preorder(root.right);
    /** Inner class tree node */
    private static class TreeNode {
    Object element;
    TreeNode left;
    TreeNode right;
    public TreeNode(Object o) {
    element = o;
    /** Get the number of nodes in the tree */
    public int getSize() {
    return size;
    /** Search element o in this binary tree */
    public boolean search(Object o){
    TreeNode temp = root;
    boolean found = false;
    if(temp == null)
    found = false;
    else if(((Comparable)(temp.element)).compareTo(o) == 0 && temp != null)
    found = true;
    else if(((Comparable)temp.element).compareTo(o) > 0){
    root = temp.left;
    found = search(o);
    else{
    root = temp.right;
    found = search(o);
    return found;
    /** Display the nodes in breadth-first traversal */
    public void breadthFirstTraversal(){
    TreeNode temp = root;
    // TreeNode leftChild = temp.left;
    // TreeNode rightChild = temp.right;
    MyQueue s = new MyQueue();
    s.enqueue(root);
    // while (s.getSize() == 0){
    System.out.println(s);
    // private void breadthFirstTraversal(TreeNode node){

    ChangBroot wrote:
    All the lectures I have read in the net are talking about Queue, but my problem is reading the tree in BFS Traversal order. It's almost 4 days I'm trying to solve this probelm, but can't come up with something. Any help is greatly appreciated. One simple strategy is to make an ordinary recursive traversal of the tree. Along in the traversal you keep an array of linked lists. When you visit a node you just add it to the list at the entry in the array corresponding to the depth of this node.
    After the traversal you have an array with linked lists. Each list holds the nodes found at a certain tree depth. So each list holds all nodes corresponding to a specific tree "breadth", namely all nodes found at the same tree depth.

  • Breadth first traversal

    Hi,
    I am trying to do a breadth first traversal of a tree, so that the character traversed would be inputted in the correct position in an array. any idea how can i go about it?
    This is my code for the tree:
    import java.util.*;
    import java.io.*;
    import java.lang.*;
    public class Huffman
        static char letters;
        static int frequency;
        static char frequency1;
        static int alphabet;
        static char frqtable [][];
        static char treetable[][];
        static TreeNode myTree[];
        static int i = 0;
        static int j = 0;
        static Scanner in = new Scanner(System.in);
        public static void main (String args[])throws IOException{
            setFrequencyTable();
            treetable = frqtable;
            sortArray(treetable);
            buildHuffmanTree(treetable, alphabet);
           // printGeneralTree();
         public static void setFrequencyTable() throws IOException{
            System.out.println ("Please enter number of distinct alphabet");
            alphabet = in.nextInt();
            frqtable = new char[alphabet][2];
           for (int count = 0; count<alphabet; count++){
                System.out.println ("Enter the character");
                letters = (char) System.in.read();
                frqtable[i][j] = letters;
                System.out.println ("Enter frequency");
                frequency = in.nextInt();
                frequency1 = Integer.toString(frequency).charAt(0); ;
                frqtable[i][j+1] = frequency1;
                i = i+1;
                j = 0;
        public static void sortArray (char[][]treetable){
            char templetter;
            char tempfrq;
          for (int j=0; j < frqtable.length; j++) {
            for (int i=0; i < frqtable.length-1; i++) {
                  if((treetable[1]) < (treetable[i+1][1])){
    tempfrq = (treetable[i][1]);
    templetter = (treetable[i][0]);
    (treetable[i][1]) = (treetable[i+1][1]);
    (treetable[i][0]) = (treetable[i+1][0]);
    (treetable[i+1][1]) = tempfrq;
    (treetable[i+1][0]) =templetter;
    public static void printInOrder(TreeNode root) {
    if (root != null) {
    printInOrder(root.left);
    if(root.ch == '\0'){
    System.out.println(" Traversed " + root.count);
    }else{
    System.out.println(" Traversed " + root.ch);
    printInOrder(root.right);
    public static void buildHuffmanTree(char [][] treetable, int alphabet){
    myTree = new TreeNode [alphabet];
    TreeNode leftNode, rightNode;
    TreeNode newNode = null;
    for ( int i = 0; i < alphabet; i++ ){
    myTree[i] = new TreeNode (treetable[i][0], Character.getNumericValue(treetable[i][1]));
    for (int j =((myTree.length)-1); j>0; j--){
    newNode = new TreeNode(myTree[j], myTree[j-1]);
    myTree[j] = null;
    myTree[j-1] = null;
    // j--;
    if(j!=1){
    for(int c = 0; c<(j-1); c++){
    if(myTree[c].count <= newNode.count){
    for(int x = alphabet-1; x>c; x--){
    myTree[x] = myTree[x-1];
    myTree[c] = newNode;
    c= j-1;
    }else{
    myTree[0] = newNode;

    Doobybug whether or not this is an assignment, home work, basic exercise or weekly puzzle, it has been derived for a reason, to get your mind thinking like a computer scientist. Of course if one had no knowledge of the breadth first traversal then the first intelligent action on their behalf would be to do some research, aka google/wikipedia. Hopefully at which point you understand the algorithm and you can apply a general set of instructions on a piece of paper using a pen. Write down exactly what is required with your understanding of the algorithm, draw a very basic binary tree and apply your technique. Does it work? If not don't worry this was only your first attempt, think about whats missing and apply a new technique based upon the algorithm again using only pen and paper.
    The sooner you can think for yourself the better.
    p.s. That was my technique whilst learning binary trees in first year.
    Mel

  • My first Mac and first experience with iPhoto.  Need help

    Hello everyone. I just purchased my first Mac, a Mini, last week and I'm trying to learn how iPhoto works. I've been able to import picturs from my NAS (network attached storage) drive which holds all our photos, music and videos.
    However, when I took pictures over the weekend, I wanted to put them on the NAS as well and have them automatically import into iPhoto. I like that iPhoto lets you put a description about the pictures, but I can't find a way to type a description and then set iPhoto to save the pictures to my NAS drive.
    I ended up just saving them to the NAS drive and then importing again and telling iPhoto to not import duplicates. The problem with that is I get folders called thumbnails and then I get messages telling me the Thumbs.db files are not readable and those are coming from my camera card or the NAS drive, maybe because it was formatted on a PC. I know Thumbs is a PC item.
    With my old PC, it allowed me to pick where I wanted my photos stored and what name I would like to call the pictures and then it named them all in succession automatically. Will iPhoto do this and if so, how do I do that? And how do I enter descriptions about my old photos to make them easier to find during a search?
    Thanks for the help. While the Mac is very similar to my old PC, there sure are a lot of things I'm unfamiliar with. But with time and some help from experts like you, I'm sure I'll get comfortable with it.
    John

    John
    iPhoto is a photo organiser - that is a database. Like any database the data has to be imported into the application.
    What format is that NAS? iPhoto does not sit happily on disks that are not formatted for Mac OS X (journalled). You will find issues with saving changes to the db and with sharing pics among other apps.
    You can put a library on an external disk:
    1. Quit iPhoto
    2. Copy the iPhoto Library Folder as an entity from your Pictures Folder to the External Disk.
    3. Hold down the option (or alt) key while launching iPhoto. From the resulting menu select 'Choose Library' and navigate to the new location. From that point on this will be the default location of your library.
    4. Test the library and when you're sure all is well, trash the one on your internal HD to free up space.
    With my old PC, it allowed me to pick where I wanted my photos stored and what name I would like to call the pictures and then it named them all in succession automatically. Will iPhoto do t
    No. For a start, filenames have no relevance in iPhoto - it's all about visual organisation. You can attach titles, keywords and comments to pics, of course, and can add them to the File on export.
    If you want to set the pics in a spot, then do that with the Finder and thereafter import them. You can use a batch file renamer such as FileList to rename the files prior to import.
    and telling iPhoto to not import duplicates.
    Using a Referenced rather than a Managed library means that iPhoto will not copy the files, but rather simply reference them on your HD. It will create an alias to the Original file, a thumbnail and, if you modify the pics, a Modified version.
    However, you need to be aware of a number of potential pitfalls using this system.
    1. Import and deleting pics are more complex procedures
    2. You cannot move or rename the files on your system or iPhoto will lose track of them
    3. Most importantly, migrating to a new disk or computer can be much more complex.
    Always allowing for personal preference, I've yet to see a good reason to run iPhoto in referenced mode unless you're using two photo organisers.
    As a general comment: iPhoto is a bit different from most photo apps. It's happiest when it manages the files and lets you go on to manage your Photos. That's a key distinction though, between Files and Pictures. iPhoto is about Pictures, not Files.
    You do all your work in the iPhoto Window - there is never a need to go into the Photo Library on the Hard Disk. To find and access photos:
    There are many, many ways to access your files in iPhoto:
    For 10.5 users: You can use any Open / Attach / Browse dialogue. On the left there's a Media heading, your pics can be accessed there. Apple-Click for selecting multiple pics.
    To upload to a site that does not have an iPhoto Export Plug-in the recommended way is to Select the Pic in the iPhoto Window and go File -> Export and export the pic to the desktop, then upload from there. After the upload you can trash the pic on the desktop. It's only a copy and your original is safe in iPhoto.
    This is also true for emailing with Web-based services. If you're using Gmail you can use THIS
    If you use Apple's Mail, Entourage, AOL or Eudora you can email from within iPhoto.
    If you use a Cocoa-based Browser such as Safari, you can drag the pics from the iPhoto Window to the Attach window in the browser.
    Or, if you want to access the files with iPhoto not running, then create a Media Browser using Automator (takes about 10 seconds) or use THIS
    Other options include:
    1. *Drag and Drop*: Drag a photo from the iPhoto Window to the desktop, there iPhoto will make a full-sized copy of the pic.
    2. *File -> Export*: Select the files in the iPhoto Window and go File -> Export. The dialogue will give you various options, including altering the format, naming the files and changing the size. Again, producing a copy.
    3. *Show File*: Right- (or Control-) Click on a pic and in the resulting dialogue choose 'Show File'. A Finder window will pop open with the file already selected.
    To use an external editor
    You can set Photoshop (or any image editor) as an external editor in iPhoto. (Preferences -> General -> Edit Photo: Choose from the Drop Down Menu.) This way, when you double click a pic to edit in iPhoto it will open automatically in Photoshop or your Image Editor, and when you save it it's sent back to iPhoto automatically. This is the only way that edits made in another application will be displayed in iPhoto.
    By all means post again if you need more info.
    Regards
    TD

  • Excel Insert Graph (Need Help!)

    Hi there!
    I am new to LabView, and trying to use the Excel Insert Graph vi. I am not sure what it means by "report in", I have tried to convert my file path for my Excel report into a string, but it won't take it, and the help says "links a report to the vi's used to control report appearance, data, and printing." Do I have to use another vi to open the Excel file first? Any help would be appreciated, thanks!
    Ke
    Message Edited by Ke Sun on 10-19-2006 04:35 PM

    Take a look at the example VIs in your [LabVIEW]\examples\office folder.  There are several examples that deal with Excel and Graphs in MSGraph Examples.llb.  You must use the "New Report.vi" to generate a new report, which gives you the reference you can then use with the Excel Insert Graph.vi.  The examples should point you in the right direction.
    Good luck,
    -D
    Darren Nattinger, CLA
    LabVIEW Artisan and Nugget Penman

  • Drawing Custom 2D Graph : Need Help!

    Hi,
    I'm new to this forum, but I figured this would be the best place to ask for help.
    I'm currently working on a new project; a Graphing Calculator for algoriths and such. I've been with Java for a while now, but I have ran into a few snags with my new project.
    [1] For now, I have a line wizard that seperates a algorithm (linear, polynomial only for now) into chunks. How would I go out Parsing it totally from a string, in any format. I need to include such mathmatical operations such as sin( , cos( and ect. I have not even started on a rough draft yet, because I don't know where to start.
    [2] My custom GraphClass is having a hard time repersenting different rates for minium and maxium axis size. For some reason both axis wont draw in the right spot, meaning my X() and Y() are coded wrong. This is some of my code for now:
    For the full class file goto : [http://pastebin.com/Ty9ndCc4]
    public int width = 390;
    public int length = 390;
    public static int minX = (int) -200;
    public static int maxX = (int) 200;
    public static float XScale = 390/ ( Math.abs(maxX)  +Math.abs(minX) );+
    +public static int minY = (int) -200;+
    +public static int maxY = (int) 200;+
    +public static float YScale = 390/ ( Math.abs(maxY)+  Math.abs(minY) );
    public static int X() {
         return (int) ((int) Math.round(abs(minX)*(float)XScale));*
    *public static int Y() {*
    *return (int) 390 - ((int) Math.round(abs(minY)*(float)YScale)); // 390 -  *because of the Y axis being upside down*
    *// This works very well. LineDirection is a made class. Pretty simple to figure out.*
    *public void drawLine(Graphics g, LineDirection dir) {*
    *if (!dir.isActivated())*
    *return;*
    *Point[] points = dir.getPoints();*
    *Color defaultColor = g.getColor();*
    *g.setColor(dir.getColor());*
    *for (int i = 1; i < points.length; i++) {*
    *int X1 = (int) points[i-1].getX();*
    *int Y1 = (int) points[i-1].getY();*
    *int X2 = (int) points.getX();*
    *int Y2 = (int) points[i].getY();*
    g.drawLine((int) X()  +(int)(X1XScale),(int)Y()+ (int)(Y1*YScale* -1),(int) X() +(int)(X2*XScale),(int) Y()+ (int)(Y2*YScale * -1));
    g.setColor(defaultColor);
    public void drawDefaultGrid(Graphics g) {
    g.drawLine(0, Y() , width, Y());
    g.drawLine(X(), 0, X(), length);
    [http://pastebin.com/Ty9ndCc4]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    RedDevil_05 wrote:
    [1] For now, I have a line wizard that seperates a algorithm (linear, polynomial only for now) into chunks. How would I go out Parsing it totally from a string, in any format. I need to include such mathmatical operations such as sin( , cos( and ect. I have not even started on a rough draft yet, because I don't know where to start.Here is a thread that may contain your answer: using the [JavaScript Engine|http://forums.sun.com/thread.jspa?threadID=5144807] to evaluate the String containing the expression.
    [2] My custom GraphClass is having a hard time repersenting different rates for minium and maxium axis size. For some reason both axis wont draw in the right spot, meaning my X() and Y() are coded wrong. This is some of my code for now:The X axis in Java is just standard increasing to the right and decreasing to the left, therefore, you can easily center by just dividing your maximum X by 2 for a center position. Y on the other hand is going to be a little more difficult, since the Y will be decreasing in the upward direction and increasing downward. You can easily get the center the same way as with the X axis (divid by 2), but then when you plot, you just change the sign on all of your Y coordinates.
    I prefer to use a BufferedImage for my graphics, line graphs or custom rendering for games and etc. I can work with that and it will then easily render onto the graphics context of a JPanel.
    Hope this help you out.
    BTW: your posted code seems to have been gnawed on by an ugly moster or something--it is hideously corrupted, but your link showing your full source shows decent enough code.

  • First time to build computer - Need help

    Hello, I just finished putting my computer together.  It was my first time and I think everything went pretty well.  I just finished putting Windows XP on it.  However, I have a few questions/problems still:
    1) Whenever I turn the computer on it still has a screen with Platinum on it saying tab to post | del to enter bios.  Is this normal?
    2) After that screen goes away, it stops loading and says "Press F1 to continue, DEL to enter SETUP" and I have to make a selection.
    3) After I press F1 to continue it says Press<Ctrl+S> or F4 to enter Raid Utility, but I dont have any raid stuff.  If i leave it alone, then it enters into XP
    4) After XP loads, if I try to goto my computer I get a blue screen.  It says MACHINE_CHECK_EXCEPTION on it towards the top.  Towards the bottom it says
    *** STOP: 0x00000009C (0x00000 and some more numbers).  How do I fix this.  I don't know if this helps, but I have a 200GB harddrive that was brand new, and whenever I booted with XP CD it said it only saw 131,000+ MB.  I said to format anyway, hope that didn't screw me up.
    Thanks for the help.

    1.  It's a normal default setting for the bios screen to show the logo.  I personally don't like it, so I turned it off.  You can access it in the "Advanced BIOS" page of the bios.
    2.  Something must be in error to have the system stop booting.  The bios only stops on errors.  I wouldn't be overly concerned yet though.  Default settings on the board make it stop on all errors.  It should give you a reason why it's stopping so look at the screen when it stops and tells you to hit F1.  That should give you an idea of what needs fixing.
    3.  Just turn off the RAID function.  It's in the "Integrated Peripherals" screen. 
    4.  Could be any number of reasons, checking your memory would be a good first step.  As to Windows only seeing it as 131GB, that's probably because you installed with an older version of Windows XP, before SP1.  Back then it couldn't see drives bigger then around 139GB.  Install SP2 and you shouldn't have a problem.  Just make sure that your BIOS sees it as 186GB.  That's what 200GB drives usually show up as.
    Michael

  • Breadth first traversal in PLSQL (How to implement Queue?)

    Hi,
    I have a tree Stored in different tables,basically its a XML tree and all the nodes are stored in different tables,those tables are related with integrity constraints.I want to traverse the tree using BFS algo,how can i implement a queue using PL/SQL.if u have any reference doc or any sample code to implement a queue please post in this thread.
    Thanks
    somy

    fgb wrote:
    Instead of enqueuing just rt.right, you need to enqueue all of the node's siblings before enqueuing rt.left. This would be easier if you knew whether a node was the leftmost child and only enqueing its siblings in that case.
    Thanks, that actually did it right there, I should have realized that.
    The modified code is this, for anyone interested:
    if(rt != null)
                queue.enqueue(rt);
                while(!queue.isEmpty())
                    rt = (Node)queue.dequeue();
                    left = rt.left;
                    if(left != null && left.right != null)
                        right = left.right;
                    else
                        right = null;
                    visit(rt);
                    if(left != null)
                        queue.enqueue(left);
                        while(right != null)
                            queue.enqueue(right);
                            if(right.right != null)
                                right = right.right;
                            else
                                right = null;
            }

  • Data display on Bar graphs - Needs help

    Hi,
    I am facing a problem with discoverer's bar graphs.
    There is a 2D Bar Graph, which is required to display the respective strength for all the classes on the axis(e.g regionwise sales for North, West, East, South). In Oracle discoverer the sales is shown only when the mouse is pointed over the respective bar but that too at the bottom. The fixed values of the sales is not being displayed above each bar permanently.
    But the client requirement is to display the strength for each class above each bar numerically so that a print out can be taken along with values.
    Please suggest how can this be done.
    Goga

    On the Plot Area tab, check the "Show Data Labels for bars". To the right of that, clicking the "Options" button will let you place the labels above or in the bars.
    Also, check that the graph background color is not the same as the font color.

  • Depth/Breadth First Search

    Hello all,
    I am trying to figure out how to do a depth and breadth first search on a graph of Cities, as defined below. I think that I understand the searches, but I am having an extremely difficult time figuring out how to implement them.
    If anyone has any tips, suggestions, or hints (for some reason I think I'm probably just overlooking something simple), I would greatly appreciate them.
    Thanks for any help!
    * to represent an individual city
    public class City {
        String name;
        double latitude;
        double longitude;
        ArrayList<Edge> neighbors;
        //the constructor
        public City(String name, double latitude, double longitude){
            this.name = name;
            this.latitude = latitude;
            this.longitude = longitude;
            this.neighbors = new ArrayList<Edge>();
        //to check if this city is equal to that given city
        public boolean same(City c){
            return this.name.equals(c.name) && this.latitude == c.latitude &&
                this.longitude == c.longitude;
    * to represent an edge between two cities
    public class Edge {
        City city1;
        City city2;
        double dist;
        boolean visited;
        public Edge(City city1, City city2){
            this.city1 = city1;
            this.city2 = city2;
            this.dist = this.distTo();
            this.visited = false;
         * to find the distance between the two cities in an edge
        public double distTo(){
            return Math.sqrt(((this.city1.latitude - this.city2.latitude) *
                    (this.city1.latitude - this.city2.latitude)) +
                    ((this.city1.longitude - this.city2.longitude) *
                    (this.city1.longitude - this.city2.longitude)));
    * to represent a path between two cities as a list
    * of edges
    public class Graph {
        ArrayList<Edge> alist;
        public Graph(ArrayList<Edge> alist){
            this.alist = alist;
    }

    http://en.wikipedia.org/wiki/Breadth-first_search (includes algorithm)

  • Need help on a sql query

    Hi Friends,
    I am trying to load Employees and their Assignments using APIs.
    I have various columns in my staging table like Last Name, First Name, etc., but I need help in writing query in the cursor especially for columns Emp Number and Supervisor Number.
    I have data as below
    Emp_Number     Supervisor_Number
    GE0002               GE0064
    GE0064               EG0009
    EG0009               EG0001
    100009                EG0001
    EG0001               TU0001
    Cursor I write will process the data in the same order as above, but here the problem is...
    When it processes first row, it checks for supervisor GE0064 which do not exist and so it errors out.
    Similarly for second row, it checks for supervisor EG0009 which again do not exist and so it errors out.
    So in order to prevent this, the cursor should process the rows as below
    Emp_Number     Supervisor_Number
    EG0001               TU0001
    EG0009               EG0001
    GE0064               EG0009
    GE0002               GE0064
    100009                EG0001
    By this way, Supervisor should be defined first as an employee and then it can be used as a supervisor for other employees
    is there a way that I can get the output as above(second set of data), when the table has records randomly as above(first set of data)
    Appreciate your help!
    Thanks,
    Srikanth

    Srikanth wrote:
    ... but the number of records returned by above query are lot more than number of records in the table.
    Why did the number go up?
    It's something only you can find out
    Maybe some Emp have several Supervisor(s) like
    with
    t as
    (select 'GE0002' Emp,'GE0064' Supervisor from dual union all
    select 'GE0064','EG0009' from dual union all
    select 'EG0009','EG0001' from dual union all
    select 'GE0064','100009' from dual union all
    select '100009','EG0001' from dual union all
    select 'EG0001','TU0001' from dual
    select Emp,Supervisor,lpad('_',3 * (level - 1),'_')||Emp indent
      from (select Emp,Supervisor
              from t
            union all
            select supervisor,null
              from t tt
             where not exists(select null
                                from t
                               where emp = tt.supervisor
    start with Supervisor is null
    connect by prior Emp = Supervisor
    EMP
    SUPERVISOR
    INDENT
    TU0001
    TU0001
    EG0001
    TU0001
    ___EG0001
    100009
    EG0001
    ______100009
    GE0064
    100009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    EG0009
    EG0001
    ______EG0009
    GE0064
    EG0009
    _________GE0064
    GE0002
    GE0064
    ____________GE0002
    Regards
    Etbin

  • Need help to draw a graph from the output I get with my program please

    Hi all,
    I please need help with this program, I need to display the amount of money over the years (which the user has to enter via the textfields supplied)
    on a graph, I'm not sure what to do further with my program, but I have created a test with a System.out.println() method just to see if I get the correct output and it looks fine.
    My question is, how do I get the input that was entered by the user (the initial deposit amount as well as the number of years) and using these to draw up the graph? (I used a button for the user to click after he/she has entered both the deposit and year values to draw the graph but I don't know how to get this to work?)
    Please help me.
    The output that I got looked liked this: (just for a test!) - basically this kind of output must be shown on the graph...
    The initial deposit made was: 200.0
    After year: 1        Amount is:  210.00
    After year: 2        Amount is:  220.50
    After year: 3        Amount is:  231.53
    After year: 4        Amount is:  243.10
    After year: 5        Amount is:  255.26
    After year: 6        Amount is:  268.02
    After year: 7        Amount is:  281.42
    After year: 8        Amount is:  295.49
    After year: 9        Amount is:  310.27
    After year: 10        Amount is:  325.78
    After year: 11        Amount is:  342.07
    After year: 12        Amount is:  359.17
    After year: 13        Amount is:  377.13
    After year: 14        Amount is:  395.99
    After year: 15        Amount is:  415.79
    After year: 16        Amount is:  436.57
    After year: 17        Amount is:  458.40And here is my code that Iv'e done so far:
    import javax.swing.*;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.RenderingHints;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.lang.Math;
    import java.text.DecimalFormat;
    public class CompoundInterestProgram extends JFrame implements ActionListener {
        JLabel amountLabel = new JLabel("Please enter the initial deposit amount:");
        JTextField amountText = new JTextField(5);
        JLabel yearsLabel = new JLabel("Please enter the numbers of years:");
        JTextField yearstext = new JTextField(5);
        JButton drawButton = new JButton("Draw Graph");
        public CompoundInterestProgram() {
            super("Compound Interest Program");
            setSize(500, 500);
            setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            amountText.addActionListener(this);
            yearstext.addActionListener(this);
            JPanel panel = new JPanel();
            panel.setBackground(Color.white);
            panel.add(amountLabel);
            amountLabel.setToolTipText("Range of deposit must be 20 - 200!");
            panel.add(amountText);
            panel.add(yearsLabel);
            yearsLabel.setToolTipText("Range of years must be 1 - 25!");
            panel.add(yearstext);
            panel.add(drawButton);
            add(panel);
            setVisible(true);
            public static void main(String[] args) {
                 DecimalFormat dec2 = new DecimalFormat( "0.00" );
                CompoundInterestProgram cip1 = new CompoundInterestProgram();
                JFrame f = new JFrame();
                f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                f.getContentPane().add(new GraphPanel());
                f.setSize(500, 500);
                f.setLocation(200,200);
                f.setVisible(true);
                Account a = new Account(200);
                System.out.println("The initial deposit made was: " + a.getBalance() + "\n");
                for (int year = 1; year <= 17; year++) {
                      System.out.println("After year: " + year + "   \t" + "Amount is:  " + dec2.format(a.getBalance() + a.calcInterest(year)));
              @Override
              public void actionPerformed(ActionEvent arg0) {
                   // TODO Auto-generated method stub
    class Account {
        double balance = 0;
        double interest = 0.05;
        public Account() {
             balance = 0;
             interest = 0.05;
        public Account(int deposit) {
             balance = deposit;
             interest = 0.05;
        public double calcInterest(int year) {
               return  balance * Math.pow((1 + interest), year) - balance;
        public double getBalance() {
              return balance;
    class GraphPanel extends JPanel {
        public GraphPanel() {
        public void paintComponent(Graphics g) {
            Graphics2D g2 = (Graphics2D)g;
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2.setColor(Color.red);
    }Your help would be much appreciated.
    Thanks in advance.

    watertownjordan wrote:
    http://www.jgraph.com/jgraph.html
    The above is also good.Sorry but you need to look a bit more closely at URLs that you cite. What the OP wants is a chart (as in X against Y) not a graph (as in links and nodes) . 'jgraph' deals with links and nodes.
    The best free charting library that I know of is JFreeChart from www.jfree.org.

  • Need help with first applescript@Quicktime- can't figure out a few lines...

    Ok guys I need help, here is what I want to happen. I want the script to just shorten a movie file. It should be so simple!!
    lengthofmovie = film length
    set time range from 0 to (lengthofmovie-1)
    save the movie as a new file
    That is all I want done, I am ripping my hair out of my head trying to do this. Please help me!!
    Here is my code so far:
    with timeout of 86400 seconds
    display dialog "Before beginning batch processing, make sure QuickTime Player is set to the desired export settings, and all videos to be processed are in a folder named ‘Input’ on the desktop." with icon note
    tell application "Finder"
    set the startup_disk to the name of the startup disk
    end tell
    set user to do shell script "whoami"
    set inputfoldername to "Input"
    set input_folder to startup_disk & ":Users:" & user & ":Desktop:" & inputfoldername & ":"
    set user_desktop to startup_disk & ":Users:" & user & ":Desktop:"
    set output_folder to startup_disk & ":Users:" & user & ":Desktop:Output:"
    set file_extension to "_export.mp4"
    try
    tell application "Finder"
    make new folder at user_desktop with properties {name:"Output"}
    end tell
    end try
    try
    set thefolderlist to list folder input_folder without invisibles
    repeat with x from 1 to count of thefolderlist
    set the_file to input_folder & item x of thefolderlist
    set output_file to output_folder & item x of thefolderlist & file_extension
    tell application "QuickTime Player"
    activate
    open the_file
    //change timeline, trim NEED HELP HERE
    export front document to output_file as MPEG4 using most recent settings with replacing
    close front document
    end tell
    end repeat
    on error
    display dialog "This script requires a folder named ‘" & inputfoldername & "‘ located on the desktop." with icon stop
    end try
    beep
    end timeout

    Hi plashd,
    First, I must confess that I don't know much about QuickTime. Nevertheless, while trying to understand your problem, I discovered that the AppleScript dictionaries of QuickTime Player and QuickTime 7 were very different from one another, and was unable to use the “export” command of QuickTime Player. However, I finally was able, with the following script, to use AppleScript to shorten a QuickTime movie and save it under another name:
    *set the_file to POSIX file "/Users/pierre/Desktop/MVI_0503.MOV"*
    *set output_file to "/Users/pierre/Desktop/NewMVI0503.MOV"*
    *tell application "QuickTime Player"*
    activate
    *open the_file*
    *tell front document*
    *trim from 1 to (duration - 5)*
    *save in output_file with replacing*
    *close without saving*
    *end tell*
    *end tell*
    Hope it can help.

  • Need Help in Inserting first ever record

    I need help in inserting my first ever record from an OAF page.
    I've created an AM 'MasterAM', added 'MasterVO' to it. Created a Page CreatePG which has a submit button, id = Apply
    Below is processRequest of CreateCo
    public void processRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (!pageContext.isFormSubmission()) {
    am.invokeMethod("createRecord", null);
    and below is processFormRequest
    public void processFormRequest(OAPageContext pageContext, OAWebBean webBean)
    super.processFormRequest(pageContext, webBean);
    OAApplicationModule am = pageContext.getApplicationModule(webBean);
    if (pageContext.getParameter("Apply") != null)
    OAViewObject vo = (OAViewObject)am.findViewObject("MasterVO1");
    am.invokeMethod("apply");
    pageContext.forwardImmediately("OA.jsp?page=/abcd/oracle/apps/per/selfservice/xxdemo/webui/CreatePG",
    null,
    OAWebBeanConstants.KEEP_MENU_CONTEXT,
    null,
    null,
    true,
    OAWebBeanConstants.ADD_BREAD_CRUMB_NO);
    Below are 'createRecord' and 'apply' in MasterAMImpl
    public void createRecord(){
    OAViewObject vo = (OAViewObject)getMasterVO1();
    if (!vo.isPreparedForExecution()) {
    vo.executeQuery();
    Row row = vo.createRow();
    vo.insertRow(row);
    row.setNewRowState(Row.STATUS_INITIALIZED);
    public void apply() {
    getTransaction().commit();
    When I run the page, it opens and I try to enter some data and press Apply. it does not insert into the table.
    Could anyone help me out.
    My jdeveloper version is 10.1.3.3.0.3

    I am facing the same issue.
    rows get inserted into the tbale, but only whol columns have the data.
    all the attributes are correctly mapped to view instance and view attribute.
    My VO has 1 EO and , i have joined another table to get desctriptions of the field.
    could that be the problem ?
    ex :
    select item , desc
    from t , master
    where t.cola=master.colb
    table t is the custom table I want the data to go in. but only who columns appear after commiting.
    any clues ?

Maybe you are looking for

  • SSO requires double login for partner application

    I'm having some trouble with SSO partner applications, when I login to a SSO protected application, the login works fine, but when I try to navigate to another application I'm presented with the login page again, the sso cookie seems to be working si

  • ?Embedding custom region as an extension to seeded self-service page.

    Hello Tapash/All, I am extending one of the self service pages to add extra fields on the page to capture information. This is what I am planning to do based on the comments (from Tapash) that I got from my previous post. 1. Create a custom table wit

  • Home Hub 1.0 Ethernet port 2.

    I have my PC linked to Ethernet port1.   Im trying to plug my xbox into Ethernet port 2. But it doesnt work. I swaped the around and the xbox worked fine. Please Why doesn't Port2 work or how do i get it to connect?? thx.

  • Reel to Reel tapes

    I have a *TEAC X-10R* reel to reel that plays at 7.5 ips but I have two tapes master at 15 ips. Is there a way in Logic to record the 15 ips tape playing at 7.5 ips and then speed it up in Logic to the right speed.

  • Oracle 11g  installation for Linux

    Hello, I am new to Oracle and Linux and assigned the task to install Oracle 11g on Linux enterprise edition. How do I install 11g on Linux ? I am also planning to install Oracle Application Express on the Linux machine. How do I accomplish these task