Forums

Full Version: changing the root of the radial tree layout
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

this demo tries to catch up with the radial tree demo from the (java) prefuse demos. A node becomes the new root of the tree by clicking on it. In addition a graph distance filter is applied.

Solution based on a hint given by Jeff in the sourceforge forum http://sourceforge.net/forum/message.php?msg_id=4685146

[attachment=159]

cheers

martin

ps Just discovered a problem with this one. Since the graph distance filter is applied to NodeSprite.TREE_LINKS, only the tree links of the underlying graph is displayed. But what I wanted is that all links are displayed, as in the prefuse demo. Now if I set the parameter to NodeSprite.ALL_LINKS, sometimes edges without connecting nodes are displayed. I might look into that later, but maybe somebody out there can let us know how to solve this.
Hello,

I guess I have solved the problem mentioned in the above thread.
As far as I can see there is a bug in the GraphDistanceFilter class, the depths of the nodes are not set correctly if the data is traversed in GRAPH_LINKS manner.

You can find a new version of this program as attachment.
cheers

martin



requires flare version 2008.07.29 or higher

The mentioned bug in the GraphDistanceFilter is now corrected in the flare toolkit.
Hi Martin,

thanks for your great work, it helps me a lot gettin throw the flare libraries. Your second version imho can become very unclear, so I like your first version more. It seems ok for me that you have to click on a node to see all subnodes.
Hi,

the first version shows the spanning tree over the graph and its edges, the second the complete graph within the set distance with the layout according to the spanning tree, so whatever suits and makes beings happy Big Grin


cheers

martin
Good morning,

one more comment on this, I think what is confusing here - at least it confused me in the end - is that the two demos are not displaying the same graph. Apart from the graph being randomly generated each time newly, the second graph has more edges. I did this so that more additional edges besides the spanning tree are shown, but I could have thought about mentioning it.

So both demos should display exact the same nodes if the underlying graph is the same. The second demo just shows in addition edges between nodes, which are not part of the spanning tree but part of the graph structure

cheers

martin
hi martin,

i'm despairingly trying to replace your buildGraph function (in first version of your code) by the following:

Code:
public function buildGraph(): Data {
            var data:Data = new Data();
            var objNodes:Object = new Object();
            var myXML:XML = new XML();
            var myXMLURL:URLRequest = new URLRequest("data.xml");
            var loader:URLLoader = new URLLoader(myXMLURL);
            loader.addEventListener(Event.COMPLETE, function(evt:Event):void{
                myXML = XML(loader.data);
                trace ( myXML );    
                _nodes = new Array();
                for each(var node:XML in myXML.nodes.node){
                    var id:String = node.attribute("id").toString();
                    var name:String = node.attribute("name").toString();
                    var subnode:Number = new Number(node.attribute("subnode").toString());
    
                    _nodes[id] = data.addNode();            
                    _nodes[id].data.label = name;

                }
/* the following code isn't ready yet and not what i want, i'll connect  subnodes and nodes here */
                var source:int;
                var target:int;
                for (var i:int =0; i < _nodes.length; ++i) {
                    
                    source = i
                    target = (i + 1) % _nodes.length;
                    data.addEdgeFor(_nodes[i], _nodes[target]);        
                    
                    if (Math.random()>0.5) {
                        target = (int) (Math.random() * _nodes.length);
                        data.addEdgeFor(_nodes[i], _nodes[target]);        
                    }
                }
                
            });
            return data;
        }

the data.xml files is looking like this:

Code:
<data>
    <nodes>
        <node id="1" name="A" subnode="" />
        <node id="2" name="B" subnode="1" />
        <node id="3" name="C" subnode="1" />
        <node id="4" name="D" subnode="1" />
        <node id="5" name="E" subnode="1" />
        <node id="6" name="F" subnode="2" />
    </nodes>
</data>

I think i m on the right way (at least i hope) Wink but all i get is an "TypeError: Error #1009" . Maybe somebody can explain me this error and got any ideas to integrate my xml.
Good mornign mighty,

hope you are well.
What funny coincidence, I just posted a demo covering how to read a graph from a xml file. In my post the structure is graphml, but maybe it helps you out with your problem.

http://www.goosebumps4all.net/34all/bb/s...hp?tid=127

If you need the specific xml structure you use here please let us know and I can have a look. Nevertheless, since flare now has a GraphMLConverter class it seems to be reasonable to use this format Wink

cheers

martin
thank you man, you're worth your weight in gold to me Big Grin, haha. Well, I posted what I'm trying to do with your Code here:
http://goosebumps4all.net/34all/bb/showt...hp?tid=130
If you can have a look on that, I'd be glad. Cuz some code is still hard to understand, oh well I keep studying. Smile Thank you so far!

greets,
dennis
Reference URL's