Bug in GTree.as Class - A Node with multiple parents

3 views
Skip to first unread message

igiovani

unread,
Nov 17, 2009, 11:33:54 AM11/17/09
to BirdEye, jbel...@unog.ch
In GTree.as Class there is a Dictionary property called _parentMap and
a corresponding method called get parents which returns _parentMap.
This property collects through method initTree the parent of a node.
The bug is that when a node has more than one parents then this
multiplicity cannot be captured by the code as is written. When I
needed for my application to scroll through the multiple parents of my
nodes I couldn' t achieve it with the use of the method "get
parents".
I think every developer that uses RaVis should be aware of this bug in
the sense that in object oriented programming a method should be as
general as possible and this method could be more general but it is
not apart from the fact that managing parents of a node is pretty much
serious staff.

I have located the bug in:

Class --> GTree.as
Method --> public function initTree():Dictionary

......................................................

if(_parentMap[v] == null) {
/* v is the child of u, meaning in the successor list
of u, but that does not mean it is the
* i'th child in terms of the tree the Number of all children is yet
unknown ...*/
setValues(v, u, _distanceMap[u] + 1, childcount);
// we have to increase here (i.e. after setValues)
++childcount;
queue.push(v)
}
..........................

The condition means that _parentMap[v] is loaded with the
corresponding parent of node v (through setValues() method) only once,
that is when found null. The second time that it won' t be null it can
not be loaded. Though I tried to fix the bug adding an "else" verse to
the initial code this didn' t fix the problem. I didn' have time to
check it further but I suspect that the problem is in the use of type
Dictionary for the storage of parents, which dictionaries, I think,
have an inherent difficulty (I think they can't at all) to store
several values with the same key.
In our case it would be, for instance, the same node to have 3
parents, that is :

_parentMap[v]=p1
_parentMap[v]=p2
_parentMap[v]=p3

I think dictionaries are not capable of doing the above. I am not sure
though and i couldn 't find anything when searching the web. Maybe the
type of variable/property _parentMap should change to another one...
If anyone could help it would be appreciated.
Reply all
Reply to author
Forward
0 new messages