Lattice of a Directed acyclic graph

Hi all,
What is a lattice of a directed acyclic graph?
What is the general algorithm to determine if a given DAG is a lattice?
I don't know how to start..
Thank You

> What is google?
I know, I know!
Google, a popular search engine, is a tool for finding resources on the World Wide Web. Google scans web pages to find instances of the keywords you have entered in the search box.

Similar Messages

  • How to draw a directed 2D graph in java

    how to draw a directed 2D graph in java?-if anybody can suggest some tutorials about this topic or can suggest the way to draw the graph.......how can i do that.......if the nodes of the graph has X and Y co-ordinate.........and the neighbours of each node are known.......suppose
    node1 has neighboures node2,node3 and node4.....node2 has node5 and node3 as neighbours.....in this way....so directed edge from node1 to node2,node3,and node4......
    or if u can suggest other way out......plz reply....

    prometheuzz wrote:
    JosAH wrote:
    If you can draw a line between two points (x,y) and (x',y') you can draw an edge.
    If you can draw one edge you can draw all edges of a graph.Proof by induction!
    ; )Yep, I copied/pasted exactly the same answer I gave this poster in another forum; I recognized him by his 'plz'-es and the abundance of punctuation ;-)
    kind regards,
    Jos

  • Trie or Directed acyclic word graph Implementation

    Hello all!
    I currently have implemented a wordlist for an application i have written using a HashSet. It holds around 120,000 words and takes up 12mb in memory.
    I would like to reduce the size of memory taken up by this list as it is for an app on a mobile device. I have been advised to use a Trie for this. I had a go using the code found [http://forums.sun.com/thread.jspa?threadID=5295936] and it seems to take up approx 3 times the amount of space as the hashSet, at around 30mb, which is not the desired behaviour.
    I also came across the Directed_acyclic_word_graph (DAWG) [http://en.wikipedia.org/wiki/Directed_acyclic_word_graph] info while looking at the Trie, which seems perfect for my purposes.
    I want to know, 1) any idea why the Trie increased the size of the word list? 2) Anyone know know of any open source Trie or DAWG code i could use?
    Thanks for any help!

    [cross-posted|http://stackoverflow.com/questions/3228075/hashset-of-strings-taking-up-too-much-memory-suggestions].

  • Serialization Graph and Self Referencing Objects or Circular Lists

    Hello Everybody,
    Let's say for instance you have a doubly linked circular list of some Object Obj in Java 6 and Obj implements Serializable.
    What happens when the graph is it constructed and this circular list is Serialized?
    Does the Serialization process build any sort of Direct Acyclic Graph possibly using some Topological Sort Algorithm?
    Does it fail?
    Or does it keep track of all the elements in the list that have already been serialized and ignores the elements that have been
    already serialized following the references of the objects in the circular list?
    Thanks in advance,
    Carlos.

    What happens when the graph is it constructed and this circular list is Serialized?It works. See the [Object Serialization Specification|http://java.sun.com/javase/6/docs/platform/serialization/spec/serial-arch.html].
    Or does it keep track of all the elements in the list that have already been serialized and ignores the elements that have been
    already serialized following the references of the objects in the circular list?It doesn't ignore them, it writes references to the already-written object instead of another copy. When deserializing, the references are resolved and the original object graph is restored correctly.

  • Help needed finding tools or terminology

    Third try due to login and post problems ...
    I'm looking for some tools to help me with some graphical layout needs,
    Part of my problem is that all the keywords an phrases I can think of to fo a Google or forum search bring up too much that I don't want.
    Any pointers to tools or terminology would be appreciated.
    I have a couple of graphical layout needs.
    One application needs to place 'widgets' of a few predefined types on a canvass, connect them with lines, set properties, and display them in different colors/apperance based upon their status. I'm sure everyone has encountered many applications which do this kind of thing. I even coded a couple in SWING myself. This time I hope someone has a toolkit which does all the basics and I can concentrate on my application needs.
    A similar need is a layout manage which allows selection of 'widgets' of various types and placement on a tree or directed, acyclic graph according to a limited set of rules (e.g., you can add a leaf or a branch to a branch, but you cannot add a branch to a leaf).
    A third variation allows construction of 'composit widgets' from a selection of basic widgets according to a set of rules (e.g., you can make a car using one engine, one body and 4 wheels).
    Any ideas of tools that may help me?
    Any suggestions of how/where to search to find any such tools?
    Thanks,
    -- Frank

    third time and no answer? he you will not get any answer. This looks like a general problem.
    but some terminology for you:
    - graphs
    - graph-algorithms
    - wrong forum
    - branches are leafs as long as they have no childs
    This is not a problem really belonging to swing. What you need is algorithms. So post in the algorithm forum.
    May it helps: MVC. You need the C and the M, swing will only be the V.
    There are a lot of tools out in the net for deploying graphs, with definable nodes, nodeproperties, different graphtypes. Just look out for them (graph, graph-layout,etc.)
    regards

  • How to make a DAG Strongly Connected?

    How to make a Directed Acyclic Graph a Strongly Connected one by adding minimum number of edges into it?
    Thanks

    anryb wrote:
    How to make a Directed Acyclic Graph a Strongly Connected one by adding minimum number of edges into it?A strongly connected graph has a path from every vertex A to evey vertex B but then a path from B to A exists as well violating the acyclic directed property of the graph.
    Or is the graph allowed to lose its DAG property in the process?
    kind regards,
    Jos

  • Connect by prior repeating nodes

    I have a hierarchical structure (a directed acyclic graph with a root node) and I want to list only the leaf nodes for a root node. For example, say I have the following graph
    A -> B, A->C, A->D
    B->C,
    C->D,
    D->E,
    D->F
    I want to get the results as A ->E, A->F
    Queries to create the above graph
    create table test_hierarchy (parent varchar2(10), child varchar2(10));
    insert into test_hierarchy (parent, child) values ('a','b');
    insert into test_hierarchy (parent, child) values ('a','c');
    insert into test_hierarchy (parent, child) values ('a','d');
    insert into test_hierarchy (parent, child) values ('b','c');
    insert into test_hierarchy (parent, child) values ('b','d');
    insert into test_hierarchy (parent, child) values ('c','d');
    insert into test_hierarchy (parent, child) values ('d','e');
    insert into test_hierarchy (parent, child) values ('d','f');
    To achieve the desired output i have written the following query
    Select connect_by_root(parent), child from test_hierarchy where connect_by_isleaf = 1
    start with parent = 'a'
    connect by prior child = parent
    But I get the result set with A->E and A->F repeated 6 times from all the possible paths.
    This is making the whole operation very slow in the production env. Adding distinct is making it even slower.
    Is there a way for me to specify to the db to not traversed the already traversed paths.
    Any help is highly appreciated

    Hi,
    [email protected] wrote:
    Thanks ... but as far as I know the recursive with clause is supported only in Oracle 11g. And my client is using Oracle 10g. Also, I have not tried this on oracle 11g instance but I am assuming that the output and query you wrote below is for oracle only.
    Also, as per Franks suggestion; I did some reading on pipelined functions. Basically, I tried creating a function (not pipelined) that will take a collection and a string. The function would update the collection to have this string if it is not present already in the collection. And would return true if the collection gets modified, false otherwise.
    But now am stuck because i cannot call this function in sql query as it has an out parameter. Functions that have OUT parameters, or that return data types not found in SQL (even BOOLEAN), can only be called from PL/SQL. They can not be used in SQL statements, even SQL statements embedded in PL/SQL.
    I suggest a function that takes one IN-argument, a string (such as 'A'), that returns a delimited string (such as 'E,F'). You could split that string into parts after it was returned, if necessary.
    So you might call the function in a SQL statment like this:
    SELECT  get_leaves ('A')
    FROM    my_table;and it would display
    GET_LEAVES
    E,FInside get_leaves, you can use whatever other functions yu want, including functions with user-defined arguments and return values. (OUT arguments in functions are not very good programming, but they would be allowed, if you really want them.)
    It's only inside get_leaves that you need to keep track of what nodes have been visited already; the calling program doesn't need to see that part of the job at all.

  • 'Level Function' Not clear

    Hi
    When i am running the following statement I get the answer as desired i.e. for the input string as 'Table' I get the output as
    T
    Ta
    Tab
    Tabl
    Table
    select (substr('&a',1,level)) from dual connect by level <=length('&a')     
    But when I give the following statement I do not get the sysdate displayed 10 times
    select sysdate from dual connect by level <=10

    'Level Function' Not cleardefinitely, I said that a million years ago. Level without prior just make no sense.
    As documented in 7,8.0,8i,9iR1,9iR2,10gR1,10gR2, connect by without prior is illegal.
    SCOTT@LSC73/9.2.0.7
    SQL> select sysdate from dual connect by level <=10
    SYSDATE
    27.12.2005 12:56:15
    SYS@LSC63 AS SYSDBA/10.2.0.1
    SQL>  select sysdate from dual connect by level <=10;
    SYSDATE
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    27.12.2005 12:57:31
    SYS@LSC70 AS SYSDBA/8.1.7.4
    SQL> select sysdate from dual connect by level <=10;
    SYSDATE
    27.12.2005 12:58:23it is "neat", but use it at your own risk...
    Message was edited by:
    Laurent Schneider
    Directed Acyclic Graph shows that one row could not appear twice (in a "hierarchy with connect by").

  • Scheduling in BPEL

    Hi all!
    All you know that BPEL can do next thing:
    When we have a consistency of jobs (tasks, etc.) to do, usually it performed by directed acyclic graph (DAG). And some jobs we can execute parallel.
    Also we have servers to execute jobs on it.
    So, the question is: how BPEL constructs parallel schedule to optimize execution of jobs.
    I mean the policy of assignation jobs to servers.
    Any information - greets!
    Thanks for attention
    PS: Sorry for my English ;-)

    BPEL is capable of parallel processing - for externalised services too (so you can deploy these one on a different server too) - or in a different BPEL domain (on the same server)..
    hth clemens

  • Drawing a DAG

    I need advice on how to go about drawing a DAG (directional acyclic graph). Alot of stuff on the Internet about traversing a DAG and analyzing a DAG but I couldn't find any info about a algorithm to actually draw the graph. Anyone know any resources that can help ?

    Try the following. You almost had it correct.
    import java.awt.*;
    import javax.swing.*;
    import com.ibm.graph.*;
    import com.ibm.graph.layout.*;
    import com.ibm.graph.draw.*;
    import com.ibm.graph.ext.visual.*;
    import com.ibm.research.util.*;
    import java.util.*;
    public class GraphDraw  extends Canvas{
      private Graph graph;
      private int xOrigin = 200;
      private int yOrigin = 200;
      private int layout = 0;
      public GraphDraw(int layout)
        // create graph
        this.graph = new Graph();
        this.layout = layout;
      public void setup() {
        try {
          // set up the graph
          Vertex v1 = new Vertex();
          v1.setName("A");
          Vertex v2 = new Vertex();
          v2.setName("B");
          Vertex v3 = new Vertex();
          v3.setName("C");
          Vertex v4 = new Vertex();
          v4.setName("D");
          Edge e12 = new Edge(v1, v2);
          Edge e13 = new Edge(v1, v3);
          Edge e14 = new Edge(v1,v4);
          Edge e23 = new Edge(v2,v3);
          Edge e24 = new Edge(v2,v4);
          Edge e34 = new Edge(v3,v4);
          graph.add(v1);
          graph.add(v2);
          graph.add(v3);
          graph.add(v4);
          graph.add(e12);
          graph.add(e13);
          graph.add(e14);
          graph.add(e23);
          graph.add(e24);
          graph.add(e34);
          // tell graph how to lay itself out
          graph.setRoot(v1, true);
         if(layout==1)
           System.out.println("Using Glow97 layout");
           LayoutGlow97 manager = new LayoutGlow97();
           manager.setOptimalEdgeLength(100.0);
           manager.setRepulsionConstant(10.0);
           manager.setIterationsImproveVertexLocation(100);
           graph.setGraphLayoutManager(manager);
         } else {  // default layout
           System.out.println("Using DAG layout");
         // the set x and y of the root does not appear to work.
         // thats a bit strange, however a work around exists in the paint method
           LayoutDAG manager = new LayoutDAG();
           manager.setX0(xOrigin);
           manager.setY0(yOrigin);
           manager.setXSpaceMultiplier(2);
           manager.setYSpaceMultiplier(2);
           graph.setGraphLayoutManager(manager);
         // The following has to be done after the edges/vertices are added to the
         // graph. (does not work otherwise)
          // you were on the correct path here. Set up a method of drawing
         // say how graph will be drawn
         DrawNetEdgesThenVertices dn = new DrawNetEdgesThenVertices();    
         graph.setDrawable(dn);
         // say how vertices will be drawn
         Draw3VertexRectangleKeyText dv = new Draw3VertexRectangleKeyText();
         dv.setColorOutline(java.awt.Color.BLUE);
         graph.setDrawableVertices(graph,dv);
         // say how edges will be drawn
         Draw2EdgeLine de = new Draw2EdgeLine();
         de.setColorPath(java.awt.Color.RED);
         graph.setDrawableEdges(graph,de);
        graph.layout();
      } catch (Exception e) {
        e.printStackTrace();
    this.setSize(600, 400);
    this.setVisible(true);
    public void paint (Graphics g) {
      try {
        super.paint(g);
        // quick hack to make the origin of the root work (translate the graphics to
        // the required offset) This may not work with other Layouts
        g.translate(xOrigin,yOrigin);
        graph.draw(g);
      } catch (Exception e) { e.printStackTrace(); }
    public static void main(String[] args) {
      if(args.length!=1) {
        System.out.println("please enter a layout to use");
        System.exit(1); 
      int layout = 0;
      try{
        layout = Integer.parseInt(args[0]);
      }catch(NumberFormatException nfe) {
         System.out.println("Error. You did not enter an integer");
         System.exit(2);
      JFrame f = new JFrame();
      f.setSize(800,600);
      GraphDraw gd = new GraphDraw(layout);
      gd.setup();
      f.getContentPane().add(gd);
      f.show();
    }The LayoutDAG layout method does not seem to honour the root positions
    that you specify. Don't know why but the easy work around is to
    translate the graphics context before you draw to it. (see the paint
    method).
    The Glow97 algorithm is a bit more tricky to use. It is an iterative
    optimisation technique. This means that the graphics can appear almost
    anywhere on the screen. So you will have to find where they are before
    you attempt to draw them or they may well be off screen.
    The Glow97 does allow you to refine the layout if you arn't satisfied.
    I'm still trying to figure out the best way of drawing buttons instead
    of vertices. It will probably involve subclassing one of the Draw?Vertex
    classes to draw a button rather then a rectangle or oval.
    matfud

  • How to save graphs or integrate with PDF???

    Hi All ,
        I want to display graph in PDF document . As it is not possible to put graph directly into interactive forms, can i directly save graph as image file through coding and then insert that image into interactive form????
    Regards
    Kavita
    Edited by: kavita chavan on Jan 7, 2008 3:16 AM

    Hi All ,
        I want to display graph in PDF document . As it is not possible to put graph directly into interactive forms, can i directly save graph as image file through coding and then insert that image into interactive form????
    Regards
    Kavita
    Edited by: kavita chavan on Jan 7, 2008 3:16 AM

  • Can we plot a unidirectional tree graph in ADF?

    Hi,
    Is it possible to make a directional tree graphs in ADF?
    I'll put up an example of what I want to plot on the graph.
    Lets say a person P1 can reach location L1 using 4 streets (A,B,C,D,E). And these are the routes he can use:
    P1->A->C->L1
    P1->D->E->L1
    P1->E->L1
    I want to plot a graph that has P1 at one end, L1 at the other end and all the paths he can take.
    Thanks,
    Hozy

    Hi,
    don't think there is such a component
    But have a look yourself. We are hosting an online demo:
    http://jdevadf.oracle.com/adf-richclient-demo/faces/index.jspx
    Select the Ddata Visualization node to see all the graph types we offer
    Frank

  • Construire graph origin ou excel

    quelqu'un pourrais me dire comment on peut construire directement un graph sous origin (ou au pire sous excel) avec un fichier tableau 2colonnes. en fait apres avoir receuillie toutes mes valeures sur un fichier je voudrais en meme temps que labview m'ouvre origin et me trace le graph correspondant! c'est possible?
    merci
    thierry

    Je ne l'ai jamais fait, mais je suis à peu près sur que c'est possible de le faire sous Excel par ActiveX
    (je ne connair pas Origin.. c'est un tableau libre je suppose, non ?)
    Je te joins un exemple présent dans LabVIEW en esperant que cela puisse t'inspirer.
    Sinon, en postant le même message en anglais, tu as beaucoup plus de chance de recevoir une réponse plus précise
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"
    Attachments:
    Write Table To XL.vi ‏87 KB

  • I'm trying to void bits of my data

    I'm working with the Dijkstra algorithm looking at the connection of nodes, well I need to know how to void a line segment, or segments, that are formed by two nodes, however leave the nodes them self intact. How can I do that? My data is given in the form, From(node)  To(node)  Cost(some value). And here is the code it self:
    import java.io.FileReader;
    import java.io.InputStreamReader;
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.util.Collection;
    import java.util.HashMap;
    import java.util.LinkedList;
    import java.util.List;
    import java.util.Map;
    import java.util.NoSuchElementException;
    import java.util.PriorityQueue;
    import java.util.Queue;
    import java.util.StringTokenizer;
    import weiss.nonstandard.PairingHeap;
    // Used to signal violations of preconditions for
    // various shortest path algorithms.
    class GraphException extends RuntimeException
        public GraphException( String name )
            super( name );
    // Represents an edge in the graph.
    class Edge
        public Vertex     dest;   // Second vertex in Edge
        public double     cost;   // Edge cost
        public Edge( Vertex d, double c )
            dest = d;
            cost = c;
    // Represents an entry in the priority queue for Dijkstra's algorithm.
    class Path implements Comparable<Path>
        public Vertex     dest;   // w
        public double     cost;   // d(w)
        public Path( Vertex d, double c )
            dest = d;
            cost = c;
        public int compareTo( Path rhs )
            double otherCost = rhs.cost;
            return cost < otherCost ? -1 : cost > otherCost ? 1 : 0;
    // Represents a vertex in the graph.
    class Vertex
        public String     name;   // Vertex name
        public List<Edge> adj;    // Adjacent vertices
        public double     dist;   // Cost
        public Vertex     prev;   // Previous vertex on shortest path
        public int        scratch;// Extra variable used in algorithm
        public Vertex( String nm )
          { name = nm; adj = new LinkedList<Edge>( ); reset( ); }
        public void reset( )
          { dist = Graph.INFINITY; prev = null; pos = null; scratch = 0; }   
        public PairingHeap.Position<Path> pos;  // Used for dijkstra2 (Chapter 23)
    // Graph class: evaluate shortest paths.
    // CONSTRUCTION: with no parameters.
    // ******************PUBLIC OPERATIONS**********************
    // void addEdge( String v, String w, double cvw )
    //                              --> Add additional edge
    // void printPath( String w )   --> Print path after alg is run
    // void unweighted( String s )  --> Single-source unweighted
    // void dijkstra( String s )    --> Single-source weighted
    // void negative( String s )    --> Single-source negative weighted
    // void acyclic( String s )     --> Single-source acyclic
    // ******************ERRORS*********************************
    // Some error checking is performed to make sure graph is ok,
    // and to make sure graph satisfies properties needed by each
    // algorithm.  Exceptions are thrown if errors are detected.
    public class Graph
        public static final double INFINITY = Double.MAX_VALUE;
        private Map<String,Vertex> vertexMap = new HashMap<String,Vertex>( );
         * Add a new edge to the graph.
        public void addEdge( String sourceName, String destName, double cost )
            Vertex v = getVertex( sourceName );
            Vertex w = getVertex( destName );
            v.adj.add( new Edge( w, cost ) );
         * Driver routine to handle unreachables and print total cost.
         * It calls recursive routine to print shortest path to
         * destNode after a shortest path algorithm has run.
        public void printPath( String destName )
            Vertex w = vertexMap.get( destName );
            if( w == null )
                throw new NoSuchElementException( "Destination vertex not found" );
            else if( w.dist == INFINITY )
                System.out.println( destName + " is unreachable" );
            else
                System.out.print( "(Cost is: " + w.dist + ") " );
                printPath( w );
                System.out.println( );
         * If vertexName is not present, add it to vertexMap.
         * In either case, return the Vertex.
        private Vertex getVertex( String vertexName )
            Vertex v = vertexMap.get( vertexName );
            if( v == null )
                v = new Vertex( vertexName );
                vertexMap.put( vertexName, v );
            return v;
         * Recursive routine to print shortest path to dest
         * after running shortest path algorithm. The path
         * is known to exist.
        private void printPath( Vertex dest )
            if( dest.prev != null )
                printPath( dest.prev );
                System.out.print( " to " );
            System.out.print( dest.name );
         * Initializes the vertex output info prior to running
         * any shortest path algorithm.
        private void clearAll( )
            for( Vertex v : vertexMap.values( ) )
                v.reset( );
         * Single-source unweighted shortest-path algorithm.
        public void unweighted( String startName )
            clearAll( );
            Vertex start = vertexMap.get( startName );
            if( start == null )
                throw new NoSuchElementException( "Start vertex not found" );
            Queue<Vertex> q = new LinkedList<Vertex>( );
            q.add( start ); start.dist = 0;
            while( !q.isEmpty( ) )
                Vertex v = q.remove( );
                for( Edge e : v.adj )
                    Vertex w = e.dest;
                    if( w.dist == INFINITY )
                        w.dist = v.dist + 1;
                        w.prev = v;
                        q.add( w );
         * Single-source weighted shortest-path algorithm.
        public void dijkstra( String startName )
            PriorityQueue<Path> pq = new PriorityQueue<Path>( );
            Vertex start = vertexMap.get( startName );
            if( start == null )
                throw new NoSuchElementException( "Start vertex not found" );
            clearAll( );
            pq.add( new Path( start, 0 ) ); start.dist = 0;
            int nodesSeen = 0;
            while( !pq.isEmpty( ) && nodesSeen < vertexMap.size( ) )
                Path vrec = pq.remove( );
                Vertex v = vrec.dest;
                if( v.scratch != 0 )  // already processed v
                    continue;
                v.scratch = 1;
                nodesSeen++;
                for( Edge e : v.adj )
                    Vertex w = e.dest;
                    double cvw = e.cost;
                    if( cvw < 0 )
                        throw new GraphException( "Graph has negative edges" );
                    if( w.dist > v.dist + cvw )
                        w.dist = v.dist +cvw;
                        w.prev = v;
                        pq.add( new Path( w, w.dist ) );
         * Single-source weighted shortest-path algorithm using pairing heaps.
        public void dijkstra2( String startName )
            PairingHeap<Path> pq = new PairingHeap<Path>( );
            Vertex start = vertexMap.get( startName );
            if( start == null )
                throw new NoSuchElementException( "Start vertex not found" );
            clearAll( );
            start.pos = pq.insert( new Path( start, 0 ) ); start.dist = 0;
            while ( !pq.isEmpty( ) )
                Path vrec = pq.deleteMin( );
                Vertex v = vrec.dest;
                for( Edge e : v.adj )
                    Vertex w = e.dest;
                    double cvw = e.cost;
                    if( cvw < 0 )
                        throw new GraphException( "Graph has negative edges" );
                    if( w.dist > v.dist + cvw )
                        w.dist = v.dist + cvw;
                        w.prev = v;
                        Path newVal = new Path( w, w.dist );                   
                        if( w.pos == null )
                            w.pos = pq.insert( newVal );
                        else
                            pq.decreaseKey( w.pos, newVal );
         * Single-source negative-weighted shortest-path algorithm.
        public void negative( String startName )
            clearAll( );
            Vertex start = vertexMap.get( startName );
            if( start == null )
                throw new NoSuchElementException( "Start vertex not found" );
            Queue<Vertex> q = new LinkedList<Vertex>( );
            q.add( start ); start.dist = 0; start.scratch++;
            while( !q.isEmpty( ) )
                Vertex v = q.remove( );
                if( v.scratch++ > 2 * vertexMap.size( ) )
                    throw new GraphException( "Negative cycle detected" );
                for( Edge e : v.adj )
                    Vertex w = e.dest;
                    double cvw = e.cost;
                    if( w.dist > v.dist + cvw )
                        w.dist = v.dist + cvw;
                        w.prev = v;
                          // Enqueue only if not already on the queue
                        if( w.scratch++ % 2 == 0 )
                            q.add( w );
                        else
                            w.scratch--;  // undo the enqueue increment   
         * Single-source negative-weighted acyclic-graph shortest-path algorithm.
        public void acyclic( String startName )
            Vertex start = vertexMap.get( startName );
            if( start == null )
                throw new NoSuchElementException( "Start vertex not found" );
            clearAll( );
            Queue<Vertex> q = new LinkedList<Vertex>( );
            start.dist = 0;
              // Compute the indegrees
              Collection<Vertex> vertexSet = vertexMap.values( );
            for( Vertex v : vertexSet )
                for( Edge e : v.adj )
                    e.dest.scratch++;
              // Enqueue vertices of indegree zero
            for( Vertex v : vertexSet )
                if( v.scratch == 0 )
                    q.add( v );
            int iterations;
            for( iterations = 0; !q.isEmpty( ); iterations++ )
                Vertex v = q.remove( );
                for( Edge e : v.adj )
                    Vertex w = e.dest;
                    double cvw = e.cost;
                    if( --w.scratch == 0 )
                        q.add( w );
                    if( v.dist == INFINITY )
                        continue;   
                    if( w.dist > v.dist + cvw )
                        w.dist = v.dist + cvw;
                        w.prev = v;
            if( iterations != vertexMap.size( ) )
                throw new GraphException( "Graph has a cycle!" );
         * Process a request; return false if end of file.
        public static boolean processRequest( BufferedReader in, Graph g )
            String startName = null;
            String destName = null;
            String alg = null;
            try
                System.out.print( "Enter start node:" );
                if( ( startName = in.readLine( ) ) == null )
                    return false;
                System.out.print( "Enter destination node:" );
                if( ( destName = in.readLine( ) ) == null )
                    return false;
                System.out.print( " Enter algorithm (u, d, n, a ): " );  
                if( ( alg = in.readLine( ) ) == null )
                    return false;
                if( alg.equals( "u" ) )
                    g.unweighted( startName );
                else if( alg.equals( "d" ) )   
                    g.dijkstra( startName );
                    g.printPath( destName );
                    g.dijkstra2( startName );
                else if( alg.equals( "n" ) )
                    g.negative( startName );
                else if( alg.equals( "a" ) )
                    g.acyclic( startName );
                g.printPath( destName );
            catch( IOException e )
              { System.err.println( e ); }
            catch( NoSuchElementException e )
              { System.err.println( e ); }         
            catch( GraphException e )
              { System.err.println( e ); }
            return true;
         * A main routine that:
         * 1. Reads a file containing edges (supplied as a command-line parameter);
         * 2. Forms the graph;
         * 3. Repeatedly prompts for two vertices and
         *    runs the shortest path algorithm.
         * The data file is a sequence of lines of the format
         *    source destination.
        public static void main( String [ ] args )
            Graph g = new Graph( );
            try
                FileReader fin = new FileReader( args[0] );
                BufferedReader graphFile = new BufferedReader( fin );
                // Read the edges and insert
                String line;
                while( ( line = graphFile.readLine( ) ) != null )
                    StringTokenizer st = new StringTokenizer( line );
                    try
                        if( st.countTokens( ) != 3 )
                            System.err.println( "Skipping ill-formatted line " + line );
                            continue;
                        String source  = st.nextToken( );
                        String dest    = st.nextToken( );
                        double    cost    = Double.parseDouble( st.nextToken( ) );
                        g.addEdge( source, dest, cost );
                    catch( NumberFormatException e )
                      { System.err.println( "Skipping ill-formatted line " + line + " because countTokens = " + st.countTokens()); }      
             catch( IOException e )
               { System.err.println( e ); }
             System.out.println( "File read..." );
             System.out.println( g.vertexMap.size( ) + " vertices" );
             BufferedReader in = new BufferedReader( new InputStreamReader( System.in ) );
             while( processRequest( in, g ) )
    }Edited by: whatzzupboy on Mar 17, 2008 3:34 PM

    Settings > Mail, Contacts, Calendars > tap email account name > Mail Days to Sync > Increase the time
    If there are no settings similar to this in the Settings app, then you won't be able to change it.

  • How to create a chart using x-y correlation line plotting and trendline?

    Hi everyone,
    I am a college student and I opted to use iWork instead Microsoft Office, which has been wonderful software until this semester (iWork '08). Currently, I am taking some science classes, which requires me to graph simple function using "excel"; since I have Numbers, I attempted to graph my homework using such software. However, it was a little disappointing because I could not find x-y correlation line plotting, trendline, or simple curve fitting in Numbers.
    Is Numbers able to graph in such way? If yes, what is the best approach to find such tools?
    Any help will be truly appreciated.
    M
    Message was edited by: MacBook it works

    Plotting a function, eg y = 2x^2 + 3x + 2 or similar, in numbers or excel / appleworks / open office is not directly possible. The indirect way to do it is to build a spreadsheet put the values of x in one column and the formula to calculate the values of y in another and use these two columns to produce a chart. As you are plotting the function via calculated data (rather than trying to find a relationship by plotting observed data) trend line or curve fitting seems unnecessary.
    You can plot observed data and produce a scatter chart in Numbers, but it will not produce a trendline for you. You could calculate the parameters of the trendline, there are a number of shareware products that will do this. See http://www.apple.com/downloads/macosx/mathscience/indexabc.html. Once you calculate the trendline you could use the technique described above to plot it.
    You can plot a function directly using Grapher which lives in the Utilities folder. It can also be used to plot data sets and do simple curve fitting.
    Hope this helps, but as always to solve a problem you have to clearly define it first.

Maybe you are looking for