COLOURING a DOUBLE sided WEIGHTED Graph.

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

COLOURING a DOUBLE sided WEIGHTED Graph.

ThSITC
Hello there,

   I really do need your JAVA help & advise again:

1.) Where do I have to lookup in the Java-Docs to find the meaning of the curious <Integer>  notation
in the SortedMap example below. Whil'st switching between so many languages, I did obviously have missed something!

Are there any current plan's to implement this in NetRexx ?

2.) Has anybody of you already any *practical experiences* with NetBeans? Is it reliable, recommandatable?
3.) I'm seeking for (maybe already existant) Method's to build my SEMANTIC GRAPH within PP.

The SEMANTIC GRAPH is a double sided, weighted graph. I do have some *very ancient* (1972!) algorithms
on my desk, originally written for my diploma thesis, for COLOURING such a graph with the MINIMUM Number
of colours (called the Chromatic Number of such a graph).

There is an upper bound (called the TURAN Number), and a LOWER Bound (cannot recall the name),
and a *VERY SPEEDY* (i.e. efficient) algorithm (at least, when I studied Mathematics), to make any and
all the COLOURING decisions, which in turn does give a DECISION SEQUENCE, and again a NEW
LOWER BOUND.

I did now translate this (very old) FORTRAN Algorithm to NetRexx (what else) but am still curious
wether their aren't already existing classes for double sided GRAPH's manipulations existing.

I am (just for info) attaching a related message below.

Alan, WHEN *NOT INTERESTED*  <blink blink>, please simply skip it... ;-)

The purpose of this, my current,  research is to use the so called *Minimal-Grad-Folge* (called MGF
in german graph theory book's), don't know the english name sorry, for a brand new algorithm
I'm writing to decide

- which PATTERN of a PROCEDURAL Program (like Rexx, PL/I, COBOL, etc)
*should belong*  ** to which OO class**                                                                                     ????????????    :-)

Anybody NOt interested in this topic: PLS. Simply ignore this message :-)

Kind greetings from dark Vienna,
Thomas Schneider-
 =============================================================================================
 

-------- Original-Nachricht --------
Betreff: [platform-dev] Re: Children.SortedMap - Going from readAccess to writeAccess
Datum: Sat, 30 Jul 2011 02:03:21 +0200
Von: Enrico Scantamburlo [hidden email]
Antwort an: [hidden email]
An: [hidden email]


My first suggestion would be to use ChildFactory instead of Children.SortedMap, or Children.Keys sorting the keys in advance
If you must use Children.SortedMap I made two examples (first time I used it), I tested them and they both works

If neither of these would work I suspect you have to create your nodes in another thread, not only the children but the parent as well.

// EXAMPLE 1
package org.scantamburlo.sortedMap;

import java.util.Random;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;

/**
 *
 * @author Enrico Scantamburlo <scantamburlo at streamsim.com>
 */
public class RootNode extends AbstractNode {

    public RootNode() {
        super(new NumberChildren());
        setName(getClass().getName());
    }

    private static class NumberChildren extends Children.SortedMap<Integer> {

        public NumberChildren() {
            Random random = new Random(999);

            for (int i = 0; i < 100; i++) {
                int num = random.nextInt();

                put(num, new NumberNode(num));
            }
        }
    }

    private static class NumberNode extends AbstractNode {

        public NumberNode(int num) {
            super(Children.LEAF);
            setName(Integer.toString(num));
        }
    }
}

// EXAMPLE2
package org.scantamburlo.sortedMap;

import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;

/**
 *
 * @author Enrico Scantamburlo <scantamburlo at streamsim.com>
 */
public class RootNode2 extends AbstractNode{

    public RootNode2() {
        super(createSortedMapChildren());
        setName(getClass().getName());
    }
   
    private static Children createSortedMapChildren(){
        Random random = new Random(999);
       
        Map<Integer, Node>  map = new TreeMap<Integer, Node>();
        for (int i = 0; i < 100; i++) {
            int num = random.nextInt();
                       
            map.put(num, new NumberNode(num));
        }
       
        Children.SortedMap<Integer>  ch = new Children.SortedMap<Integer>(map){};
       
        return ch;
    }
   
    private static class NumberNode extends AbstractNode {

        public NumberNode(int num) {
            super(Children.LEAF);
            setName(Integer.toString(num));
        }
     
    }
   
}





On Fri, Jul 29, 2011 at 9:28 PM, ilhami visne <[hidden email]> wrote:
I think this is a warning and not an Exception, you are creating your nodes inside a mutex. Try to create your child nodes before.

Yes, it happes inside the mutex (Mutex.java:684). Creating the child nodes is not the problem, but putting them into the nodes map is the problem. I have tried to put all the nodes in the constructor, did not work. Any idea where to put the nodes into the nodes map?

thanks,
ilhami visne

On Fri, Jul 29, 2011 at 8:12 PM, ilhami visne <[hidden email] <mailto:[hidden email]>> wrote:

   Hello Platform Developers,

   I want the children of a node automatically sorted. So logically
   i've used the Children.SortedMap. In the addNotify(), i fill the map
   with nodes. However i'm gettings this exception:
   "java.lang.__IllegalStateException: WARNING: Going from readAccess
   to writeAccess, see #10778:
   http://www.netbeans.org/__issues/show_bug.cgi?id=10778
   <http://www.netbeans.org/issue
s/show_bug.cgi?id=10778>"  and don't
   know what to do.

   My class (shortened) looks like this:

   private static class FunctionChildren extends
   Children.SortedMap<Integer> {

           ... //definitions

           public FunctionChildren(...) {
               super(new TreeMap<Integer,Node>());
               ...
           }

           @Override
           protected void addNotify() {
               java.util.SortedMap<Integer,__Node> map = new
   TreeMap<Integer, Node>();

               for (...) {
                   map.put(<integer value>, new XNode());
               }

               putAll(map);
           }
       }

   How can i avoid this warning?
   Best wishes,
   Ilhami Visne




--
Enrico Scantamburlo

"For people that try to compensate the lack of capacity with more effort, there is no limit to the things they cannot do"





--
Enrico Scantamburlo

"For people that try to compensate the lack of capacity with more effort, there is no limit to the things they cannot do"



--
Thomas Schneider (www.thsitc.com)

_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/

Thomas Schneider, Vienna, Austria (Europe) :-)

www.thsitc.com
www.db-123.com
Reply | Threaded
Open this post in threaded view
|

Re: COLOURING a DOUBLE sided WEIGHTED Graph.

rvjansen
Thomas,

(1) This is part of Java's generics notation. You can disregard it mostly when converting to NetRexx. It is a compile time technique to ensure the types of elements in collection classes. When you are not using it, as you are forced to do in present day NetRexx, you have to take care to cast the objects you take out of collections to their right types.

(2) NetBeans is a good IDE, and I used it a lot until they went, a number of years ago, to a rather strict enforcing of standard directories, ant, etc - up to the point that it would erase source code if it did not comply with its expectations. It has been relaxed later but its usefulness for me stayed limited when it got rid of the freedom and flexibility of the first versions. It has a good Swing visual editor that can keep the generated source code in step with your changes in the interface. If you can accommodate to its rules it is a good platform. The choice of IDE boils down to taste and experience and I think you need to check out some of the more known ones before making your own choice. But this is no place to discuss them if there is no immediate relevancy to a specific NetRexx issue.

(3) have a read of the collection classes documentation, it can help you a lot in designing your algorithms. I also found "Algorithms in Java" by Sedgewick a useful resource for these things.

best regards,

René.

On 30 jul. 2011, at 02:56, Thomas Schneider wrote:

Hello there,

   I really do need your JAVA help & advise again:

1.) Where do I have to lookup in the Java-Docs to find the meaning of the curious <Integer>  notation
in the SortedMap example below. Whil'st switching between so many languages, I did obviously have missed something!

Are there any current plan's to implement this in NetRexx ?

2.) Has anybody of you already any *practical experiences* with NetBeans? Is it reliable, recommandatable?
3.) I'm seeking for (maybe already existant) Method's to build my SEMANTIC GRAPH within PP.

The SEMANTIC GRAPH is a double sided, weighted graph. I do have some *very ancient* (1972!) algorithms
on my desk, originally written for my diploma thesis, for COLOURING such a graph with the MINIMUM Number
of colours (called the Chromatic Number of such a graph).

There is an upper bound (called the TURAN Number), and a LOWER Bound (cannot recall the name),
and a *VERY SPEEDY* (i.e. efficient) algorithm (at least, when I studied Mathematics), to make any and
all the COLOURING decisions, which in turn does give a DECISION SEQUENCE, and again a NEW
LOWER BOUND.

I did now translate this (very old) FORTRAN Algorithm to NetRexx (what else) but am still curious
wether their aren't already existing classes for double sided GRAPH's manipulations existing.

I am (just for info) attaching a related message below.

Alan, WHEN *NOT INTERESTED*  <blink blink>, please simply skip it... ;-)

The purpose of this, my current,  research is to use the so called *Minimal-Grad-Folge* (called MGF
in german graph theory book's), don't know the english name sorry, for a brand new algorithm
I'm writing to decide

- which PATTERN of a PROCEDURAL Program (like Rexx, PL/I, COBOL, etc)
*should belong*  ** to which OO class**                                                                                     ????????????    :-)

Anybody NOt interested in this topic: PLS. Simply ignore this message :-)

Kind greetings from dark Vienna,
Thomas Schneider-
 =============================================================================================
 

-------- Original-Nachricht --------
Betreff: [platform-dev] Re: Children.SortedMap - Going from readAccess to writeAccess
Datum: Sat, 30 Jul 2011 02:03:21 +0200
Von: Enrico Scantamburlo [hidden email]
Antwort an: [hidden email]
An: [hidden email]


My first suggestion would be to use ChildFactory instead of Children.SortedMap, or Children.Keys sorting the keys in advance
If you must use Children.SortedMap I made two examples (first time I used it), I tested them and they both works

If neither of these would work I suspect you have to create your nodes in another thread, not only the children but the parent as well.

// EXAMPLE 1
package org.scantamburlo.sortedMap;

import java.util.Random;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;

/**
 *
 * @author Enrico Scantamburlo <scantamburlo at streamsim.com>
 */
public class RootNode extends AbstractNode {

    public RootNode() {
        super(new NumberChildren());
        setName(getClass().getName());
    }

    private static class NumberChildren extends Children.SortedMap<Integer> {

        public NumberChildren() {
            Random random = new Random(999);

            for (int i = 0; i < 100; i++) {
                int num = random.nextInt();

                put(num, new NumberNode(num));
            }
        }
    }

    private static class NumberNode extends AbstractNode {

        public NumberNode(int num) {
            super(Children.LEAF);
            setName(Integer.toString(num));
        }
    }
}

// EXAMPLE2
package org.scantamburlo.sortedMap;

import java.util.Map;
import java.util.Random;
import java.util.TreeMap;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;

/**
 *
 * @author Enrico Scantamburlo <scantamburlo at streamsim.com>
 */
public class RootNode2 extends AbstractNode{

    public RootNode2() {
        super(createSortedMapChildren());
        setName(getClass().getName());
    }
   
    private static Children createSortedMapChildren(){
        Random random = new Random(999);
       
        Map<Integer, Node>  map = new TreeMap<Integer, Node>();
        for (int i = 0; i < 100; i++) {
            int num = random.nextInt();
                       
            map.put(num, new NumberNode(num));
        }
       
        Children.SortedMap<Integer>  ch = new Children.SortedMap<Integer>(map){};
       
        return ch;
    }
   
    private static class NumberNode extends AbstractNode {

        public NumberNode(int num) {
            super(Children.LEAF);
            setName(Integer.toString(num));
        }
     
    }
   
}





On Fri, Jul 29, 2011 at 9:28 PM, ilhami visne <[hidden email]> wrote:
I think this is a warning and not an Exception, you are creating your nodes inside a mutex. Try to create your child nodes before.

Yes, it happes inside the mutex (Mutex.java:684). Creating the child nodes is not the problem, but putting them into the nodes map is the problem. I have tried to put all the nodes in the constructor, did not work. Any idea where to put the nodes into the nodes map?

thanks,
ilhami visne

On Fri, Jul 29, 2011 at 8:12 PM, ilhami visne <[hidden email] <mailto:[hidden email]>> wrote:

   Hello Platform Developers,

   I want the children of a node automatically sorted. So logically
   i've used the Children.SortedMap. In the addNotify(), i fill the map
   with nodes. However i'm gettings this exception:
   "java.lang.__IllegalStateException: WARNING: Going from readAccess
   to writeAccess, see #10778:
   http://www.netbeans.org/__issues/show_bug.cgi?id=10778
   <http://www.netbeans.org/issue
s/show_bug.cgi?id=10778>"  and don't
   know what to do.

   My class (shortened) looks like this:

   private static class FunctionChildren extends
   Children.SortedMap<Integer> {

           ... //definitions

           public FunctionChildren(...) {
               super(new TreeMap<Integer,Node>());
               ...
           }

           @Override
           protected void addNotify() {
               java.util.SortedMap<Integer,__Node> map = new
   TreeMap<Integer, Node>();

               for (...) {
                   map.put(<integer value>, new XNode());
               }

               putAll(map);
           }
       }

   How can i avoid this warning?
   Best wishes,
   Ilhami Visne




--
Enrico Scantamburlo

"For people that try to compensate the lack of capacity with more effort, there is no limit to the things they cannot do"





--
Enrico Scantamburlo

"For people that try to compensate the lack of capacity with more effort, there is no limit to the things they cannot do"



--
Thomas Schneider (www.thsitc.com)
_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/



_______________________________________________
Ibm-netrexx mailing list
[hidden email]
Online Archive : http://ibm-netrexx.215625.n3.nabble.com/