GRAPH implementation

Hi,
I am looking for an implementation of a graph in ABAP OO. Could you give me some hints where I can find a standard implementation?
Best regards,
Fabian

Hi Fabian,
Ok I understand it somewhat now.
I did not find any implementations in OO directly so far.
In any case, see sample program NETZOCX1. It is the nearest one I can think of..
Infact all sample programs that start with NETZ*
Hope this helps..
Sri
Message was edited by: Srikanth Pinnamaneni

Similar Messages

  • Graphe implementation

    hello,
    I m working on a Ford-Fulkerson algorithm to get the Maximum flow in residual graph, and min-cost algorithm.
    My representation based on adjacency-lists approach, where I keep track of all the vertices connected to each vertex on a linked list that is associated with that vertex.
    So far I've created 4 classes:
    Edge( int cost , int capacity )
    +public int getCost()
    +public void setCost(int c)
    +public int getCapacity()
    +public void setCapacity(int c)
    Vertex( String nm )
    +public String getName()
    +public void setName(String name)
    Node(Vertex v, Edge e)
       +public Vertex getVertex()
       +public Edge getEdge()
    Graph, and contains // not programmed yet
    removeEdge
    addEdge(Vertex sourceVertex,Vertex targetVertex,Edge e)
    removeVertex(Vertex v)
    AddVertex(Vertex v)
    getEdgeCapacity(Vertex sourceVertex,Vertex targetVertex)
    getEdgeCost(Vertex sourceVertex,Vertex targetVertex)my problem is how to add node linked list associated to a specified vertex to my graph. Do I have to create a multidimensional vector(2d) that hold Vertex name in first column and linked list in second column?
    And I want to know is this the right implementation for this algorithm.
    regards

    I think you could just add the linked list inside your Vertex class. That way, you would have the Vertex object with its name and its associated linked list, and then the Edge object with the cost and capacity. But then, you could also put the cost and capacity into the Vertex object, so you have the Vertex object that has name, capacity, cost, and the linked list, all inside one object. Then for the Graph, you just create a bunch of vertices and stick them on the graph like any graph using their capacity and cost as the x and y values in whichever order you want them.

  • 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].

  • Adjacency List implementation of a graph

    Hey everyone,
    I'm starting to code a directed graph using an adjacency list and I'm running into a little trouble. I understand the concepts of the adjacency list structure, but I cant write seem to figure out how to code one. So far I'm using two doubly linked lists for storing the vertices and edges, and each is in its own class (I thought this would come in handy when later coding traversals in the graph). In the graph class, I'm thinking that an array list would work to store the adjacent vertices (each value in the array storing a list of vertices which are adjacent). However, if this is right then I'm not sure what to do with the edges, and how to make each edge know which vertices it is connecting.. In general, I'm looking for comments/advice on this type of graph implementation. Anything will help. Thanks a lot.

    import java.util.*;
    public class AdjacencyListNode
        private Set<Node> successors = new HashSet<Node>();
        public void addSuccessor(Node n) { ... }
        public boolean predecessorOf(Node n) { ... }
    }Of course, if you want multiple edges between nodes or weighted edges then it'll need modifying. You may also want to be able to apply a visitor to the successors.

  • How to display 4 graphs on the same graphs display when running the VI 4 times ?

    My goal is trying to display 4 different graphs on the the same XY graph when I run the VI 4 times. Right now, the new graph will overdrive the previous graph when I re-run the VI.
    Please help!
    Solved!
    Go to Solution.

    You need a mechanism for storing previous data; LabVIEW graphs do not have a history, they display sets of data.  A shift register is an obvious answer, but it can get somewhat "tricky" when the Build XY Graph is used as it accepts a DDT and you cannot simply append a data set using array functions...
    The solution?
    Rather than make the changes for you, I've created a simple example for a regular graph to show you how to use an un-initialized shift register to store values from previous runs (the data will be lost when the VI is closed) as long as the VI is in memory.
    I'll leave the DDT conversion from the 2D-array and XY graph implementation for you to figure out in case this is some form of a homework assignment.
    Good luck!
    -Bob
    Message Edited by B O B on 11-20-2009 04:53 PM
    -Bob
    Attachments:
    Example 2.vi ‏12 KB

  • Graphing Classes: Please Help

    I am in need of a real-Time trend graph implementation. I have not seen this on the net anywhere. I am porting over a QNX application to Java. QNX through PhaB has a real-time trend widget, we used to model data over time. Has anyone seen something similar done in Java? Any help would be appreciated. Thanks.

    JFreeChart might do what you want:
    http://www.object-refinery.com/jfreechart/index.html
    It's not really designed for real time charts (each data change redraws the whole chart) but if you are only updating the chart every 5 seconds or so, it might meet your requirements.
    JFreeChart is open source (LGPL) so it will only cost you your time to evaluate it...
    Regards,
    Dave Gilbert
    www.object-refinery.com

  • Why is there no graph?

    Why doesn't the collections API include a graph implementation? A single/double edged and weighted graph might prove useful at times. Is it because these things can be represented with existing collections? If not, does anybody know of open source implementations of these types of structures? All I can seem to find are academic examples used for CS homework assignments.

    you might look for a "charting" project instead. they tend to include abstract graph structures, e.g. www.jgraph.com (no affiliation, just the first link i hit).

  • Bipartite graph representation

    I am trying to figure out the best way to implement a bipartite graph. So far, I am using a hashmap to keep track of vertices that link a string name to a vertex node (whose field contains an arraylist of adjacent vertices). I'm not sure if using one hashmap is ok for bipartite graph implementation. Would I need two hashmaps to keep track of vertices in each disjoint set or should I be using a completely different ADT all together? Thanks.

    Then, so far you have a fairly standard graph representation. So you have a representation of the graph. But now you think you need some special data structure to describe its bipartiteness? Okay, add that on. The vertices of the graph divide themselves into two subsets, right? So make two sets of vertices.

  • Generics in interfaces parameters

    My post is a feature request. If anyone have informations on forthcoming and related developments, please send me.
    I want to implement a graph class with nodes and edges collections and express in the implements section that this class supports such features (I don't take into account any delegation mechanism), graph can be considered as a String / Node map or as String / Edge one :
    public class Graph implements Map<String, Node>, Map<String, Edge> {
    but when compiling, I have interfaces method conflicts such as :
    "The return type is incompatible with Map<String,Edge>.get(Object), Map<String,Node>.get(Object)"
    because one get(Object) method is present in each interface. I would have rather liked to have a get(Node) and a get(Edge) methods. In other words, I would have liked to have Map<K,V>.get(K) method in Map interface.
    Does anyone know why Java Generics are not fully introduced in interfaces and maybe in some classes ? Is it a technical reason ? A workaround ? An intermediate development stage ?
    Thx.

    public class Graph implements Map<String, Node>, Map<String, Edge> {The problem is that after compilation, when the object code is produced, any "type parameter" information is erased (you need to read up on Java reflection more closely).
    Thus, there is only one Map class in the runtime (not one for every possible combination of type parameters). and any references to, say, Map<String,Node>.put() become, at runtime, just Map.put().
    So you can't do what you want, because at compile time, your two parent interfaces are "different", but at runtime, they would be the same. The message could be better, I agree.
    To do what you want:
    * If your two classes (Edge and Node) have no relationship to each other, then you'll have to implement Map<String,Object>.
    * If they do have a common ancestor, you can declare it as extending Map<String,CommonAncestor>.
    In both cases, you'll have to, e.g. downcast the result of get() to the right type.

  • Generics with recursive parameters

    Hi all,
    I'm developing a class hierarchy using generics for representing graphs in our product. I end up with a lot of types such as:
    public interface Node< T extends Node<T> >
      Set< Port<N> > getPorts();
    public interface Port< T extends Node<T> >
      etc etc
    }which has caused me to run into the following bugs:
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6548436
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6507317
    When I first started working with the hierarchy, I had a lot of code of the form:
    Set< Port< ? extends Node<?> > > = node.getPort();which triggered the above bugs all over the place. I've since found that I can use the shorter form:
    Set< Port<?> > = node.getPort();and it seems to just work. My question is: is this the same thing? Is the compiler smart enough to work out that the wildcard in Port<?> is really a T extends Node<T> because it's declared that way in the original class?
    Thanks for any help,
    Colin

    public class Graph implements Map<String, Node>, Map<String, Edge> {The problem is that after compilation, when the object code is produced, any "type parameter" information is erased (you need to read up on Java reflection more closely).
    Thus, there is only one Map class in the runtime (not one for every possible combination of type parameters). and any references to, say, Map<String,Node>.put() become, at runtime, just Map.put().
    So you can't do what you want, because at compile time, your two parent interfaces are "different", but at runtime, they would be the same. The message could be better, I agree.
    To do what you want:
    * If your two classes (Edge and Node) have no relationship to each other, then you'll have to implement Map<String,Object>.
    * If they do have a common ancestor, you can declare it as extending Map<String,CommonAncestor>.
    In both cases, you'll have to, e.g. downcast the result of get() to the right type.

  • FPM Example  (SFlightExample)

    Hi All,
    I am doing FPM application, i followed the standard example in help.sap.com too.
    Please suggest me, how to implement class SFlightConstants the names of the perspectives of the application SFlightExample and the name of the user defined event type USER_EVENT_DETAIL are defined.
    Thanks
    Karthi D.

    Hi Sowmya
    Thanks for your reply
    Can provide me details for the below steps in the same example (http://help.sap.com/saphelp_erp2005/helpdata/en/43/3b8e8cb4ab1800e10000000a1553f6/frameset.htm)
        3.      Define two more member variables in the configuration component CcSFlight. One variable of type NavigationGraph stores the navigation graph of the application and one variable of type HashMap (Java standard class) stores a list of all known perspectives.
           4.      Declare the member variables for the Perspectives.
           5.      With the member variables of the configuration component defined, implement the method loadConfiguration(), which runs on startup of the application. The method performs the following actions:
    ¡        Initializes member variables (especially the VACs and the perspectives)
    ¡        Defines the navigation graph
    ¡        Creates a list of all perspectives.
    The navigation paths and the navigation graph for the application contain five transitions between perspectives in the roadmap (see Specifying a Self-Service Application). In addition, you need one path to find the first perspective of the application.
    Use the predefined event names of interface IFPM wherever possible. Only for the transition from perspective SELECT to perspective DETAIL should you use your own event name.
           6.      After defining the navigation graph, implement the two methods getStartPerspective() and getNextPerspective(). The purpose of these methods is to check the navigation graph of the application and return the required perspective to the FPM.
    Thanks
    Karthi D.

  • Implementing a graph scrolling using JScrollPane component

    I would like to ask a question apropos using of JScrollPane component. A part of the default behaviour of this component is adjusting the component's state when the size of the client changes. But, I need to achieve an opposite effect - I need to adjust a size of my client when the size of JScrollPane (and its viewport) changes (for instance, when the user resizes the frame).
    I implement a graph component which will show the graph of a time function. This component should always show nnn seconds without connection to the size of the scroll pane's viewport. So, if the the scroll pane component is resized I need to adjust the size of my client in order to keep the displayed time period unchanged.
    Now the question: how may I check the size of the viewport when the size of the JScrollPane changes? And whether I can do it even if the JScrollPane component has no client?
    If you know any other method of achieving the same effect, plese let me know.
    Thanks.

    I still find getExten\tSize (and getViewRect) work for me. Here's another demo.
    In my component, there's a big oval thats bounded by my component and a smaller
    oval that should track with the viewport's bounds.
    import java.awt.*;
    import javax.swing.*;
    public class ViewportLemonJuice extends JPanel {
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawOval(0, 0, getWidth(), getHeight());
            Container parent = (Container) getParent();
            if (parent instanceof JViewport) {
                Rectangle rect = ((JViewport) parent).getViewRect();
                g.drawOval(rect.x, rect.y, rect.width, rect.height);
        public static void main(String[] args) {
            JComponent comp = new ViewportLemonJuice();
            comp.setPreferredSize(new Dimension(800,800));
            JScrollPane sp = new JScrollPane(comp);
            sp.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE);
            JFrame f = new JFrame("ViewportLemonJuice");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(sp);
            f.setSize(500,300);
            f.setLocationRelativeTo(null);
            f.setVisible(true);
    }

  • How to implement a simple node-edge graph?

    Can any one give me some advice on how to implement a simple node-edge graph in a frame? Every node is a rectangle which can be moved by mouse, and every edge is a arc between two nodes.
    Should the node class extend JPanel, and the edge class extend Graphics? and so on?

    It is impossible to generate similar update from OWB.
    Does your table1 contain primary key columns? What is the number of rows in this table?
    The only working solution in this case - use table1 twice in mapping - as source and as target (with UPDATE operation),
    link these operators with primary key columns and specify matching by PK columns.
    Updated column link to Constant operator attribute.
    In this case OWB generate SQL like
    merge table1 a
    using table1 b
    on (a.pk_column=b.pk_column)
    when matched then update set column1=1
    Regards,
    Oleg

  • Implementing a Graph Data Structure

    First time posting here, I was introduced to LabVIEW while participating in FIRST.
    I was reading about Graph Data Structures, and wanted to see if I could use them in LabVIEW, as it looked like a good way to relate information. Unfortunately, it appears that the straight forward way that I attempted will not work. I tried creating a typedef which consisted of a cluster of two elements, an array of linked nodes and an array of edge weights. Alas, I found you can't have recursive data types, as the array of linked nodes in the typedef needed to be the same as the typedef. I know why this is after a bit of searching, but I was wondering if there was a way to get around this. From my research, it seems like using a root class and a child class is one possible, but advanced way of doing it.
    I am currently thinking of just representing the linked nodes of a node as an array of index numbers which you can use to get the referenced nodes from the graph array. This means that the graph array cannot be sorted or otherwise modified so that the index numbers won't work, you can only add objects onto the end. Is this thinking right, or is there a different way to go about this?
    Solved!
    Go to Solution.

    Not an easy problem, as recursion is not native to LV programming (much less than any other language I used except assembler).
    But the solution to your index number problem is to use 'keys'. Each node should have a unique key (number), so you can adress it (search for the key) even if the array is sorted in some way.
    Again, it is not native to LV. This means, that you need to program the logic other languages use for that on your own (pseudo-pointers, handles, keys, hashes).
    From a practical side: I would not implement the graph in LV itself but access a graph from some other source (data base?) via an interface (ActiveX, .NET). To learn a bit more about how to do it, try playing around with the tree control (it is a limited graph).
    Felix
    www.aescusoft.de
    My latest community nugget on producer/consumer design
    My current blog: A journey through uml

  • Importing Graph Class/help implement a weighted graph class

    Is there a way to import a graph structure into my java program so that I do not need to write my own graph class?
    If not, does anyone have a graph class that I can use? I've been trying to implement this program for the past few days..
    I'm having trouble implementing a weighted graph class. This is what I have so far:
    import java.util.ArrayList;
    import java.util.Queue;
    import java.util.*;
    public class Graph<T>
         private ArrayList<Vertex> vertices;
         int size = -1;
         public Graph() throws BadInputException
              ReadFile source = new ReadFile("inputgraph.txt");
              size = source.getNumberOfWebpages();
              System.out.println(size);
              vertices = new ArrayList<Vertex>();
         public int bfs(int start, int end) //breadth first search
              Queue<Integer> queue = new LinkedList<Integer>();
              if(start == -1 || end == -1)
                   return -1;
              if(start == end)
                   return 0;
              int[] d = new int[size];
              System.out.println(size + "vertices size");
              for(int i = 0; i < d.length; i++)
                   d[i] = -1;
              System.out.println(start + " START GRAPH");
              d[start] = 0;
              queue.add(start);
              while(!queue.isEmpty())
                   int r = queue.remove();
                   if(r == end)
                        return d[r];
                   for(EdgeNode ptr = vertices.get(r).head; ptr != null; ptr = ptr.next)
                        int neighbor = ptr.dest;
                        if(d[neighbor] == -1)
                             queue.add(neighbor);
                             d[neighbor] = d[r] + 1;
                             if(neighbor == end)
                                  return d[neighbor];
              return d[end];
         public boolean addEdge(int start, int end)
              Vertex v = new Vertex();
              v = vertices.get(start);
              EdgeNode temp = v.head;
              EdgeNode newnode = new EdgeNode(end, temp);
              v.head = newnode;
              return true;
         public void setRank(int vertex, double rank) //set the weights
              vertices.get(vertex).pageRank = rank;
         public double getRank(int vertex)
              return vertices.get(vertex).pageRank;
    If anyone could help. It would be greatly appreciated
    Edited by: brones on May 3, 2008 12:33 PM

    brones wrote:
    along with the rest of my code, I'm not sure how to implement it as a weighted graphA single list is not the proper way of representing a graph. An easy way to implement a graph is to "map" keys, the source-vertex, to values, which is a collection of edges that run from your source-vertex to your destination-vertex. Here's a little demo:
    import java.util.*;
    public class TestGraph {
        public static void main(String[] args) {
            WeightedGraph<String, Integer> graph = new WeightedGraph<String, Integer>();
            graph.add("New York", "Washington", 230);
            graph.add("New York", "Boston", 215);
            graph.add("Washington", "Pittsburgh", 250);
            graph.add("Pittsburgh", "Washington", 250);
            graph.add("Pittsburgh", "New York", 370);
            graph.add("New York", "Pittsburgh", 370);
            System.out.println("New York's edges:\n"+graph.getEdgesFrom("New York"));
            System.out.println("\nThe entire graph:\n"+graph);
    class WeightedGraph<V extends Comparable<V>, W extends Number> {
        private Map<V, List<Edge<V, W>>> adjacencyMap;
        public WeightedGraph() {
            adjacencyMap = new TreeMap<V, List<Edge<V, W>>>();
        public void add(V from, V to, W weight) {
            ensureExistenceOf(from);
            ensureExistenceOf(to);
            getEdgesFrom(from).add(new Edge<V, W>(to, weight));
        private void ensureExistenceOf(V vertex) {
            if(!adjacencyMap.containsKey(vertex)) {
                adjacencyMap.put(vertex, new ArrayList<Edge<V, W>>());
        public List<Edge<V, W>> getEdgesFrom(V from) {
            return adjacencyMap.get(from);
        // other methods
        public String toString() {
            if(adjacencyMap.isEmpty()) return "<empty graph>";
            StringBuilder b = new StringBuilder();
            for(V vertex: adjacencyMap.keySet()) {
                b.append(vertex+" -> "+getEdgesFrom(vertex)+"\n");
            return b.toString();
    class Edge<V, W extends Number> {
        private V toVertex;
        private W weight;
        public Edge(V toVertex, W weight) {
            this.toVertex = toVertex;
            this.weight = weight;
        // other methods
        public String toString() {
            return "{"+weight+" : "+toVertex+"}";
    }Note that I didn't comment it, so you will need to study it a bit before you can use it. If you have further question, feel free to ask them. However, if I feel that you did not take the time to study this example, I won't feel compelled to assist you any further (sorry to be so blunt).
    Good luck.

Maybe you are looking for